0

嘿,我将如何加载此代码

http://jsfiddle.net/xw89p/

在 Visual Studio 中的一个简单的 Web 表单中。

例如,我可以将其插入

  var rotation = function (){
  $("#image").rotate({
  angle:0, 
  animateTo:360, 
  callback:enter code here rotation,
  easing: function (x,t,b,c,d){        // t: current time, b: begInnIng value,
    c: change In value, d: duration
      return c*(t/d)+b;
  }
 });
    }
    rotation();​
4

1 回答 1

0

将该代码放入一个 JavaScript 文件 (.js),然后在您的 Web 表单文件中,添加一个引用该 .js 文件的标记:

<script language="JavaScript" src="scripts.js"></script>

第二种可能性是将该代码放在 Web 表单文件的脚本标记中:

<script>
var rotation = function (){
   $("#image").rotate({
      angle:0, 
      animateTo:360, 
      callback: rotation,
      easing: function (x,t,b,c,d){        // t: current time, b: begInnIng value, c: change In value, d: duration
          return c*(t/d)+b;
      }
   });
}
$(document).ready(function(){
    rotation();​
});
</script>

当然,在包含 js 文件或内联脚本标记之前,您需要确保首先引用 jQuery 和您需要的任何其他 javascript 库。

希望这可以帮助

编辑:这是我这边的工作版本:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<img src="https://www.google.com/images/srpr/logo3w.png" id="image">​
    <script  type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script>
<script type="text/javascript">
    function rotation() {
        $("#image").rotate({
            angle: 0,
            animateTo: 360,
            callback: rotation,
            easing: function(x, t, b, c, d) { // t: current time, b: begInnIng value, c: change In value, d: duration
                return c * (t / d) + b;
            }
        });
    };
    $(document).ready(function () {
        rotation();
    })
</script>
</html>
于 2012-10-20T01:27:39.047 回答