【问题标题】:asp.net/jquery - Countdown timer not workingasp.net/jquery - 倒数计时器不起作用
【发布时间】:2010-05-19 11:39:08
【问题描述】:

这里是完整的代码:

  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
    <style type="text/css">
        @import "jquery.countdown.css";
    </style>
    <script type="text/javascript" src="Scripts/jquery.countdown.js"></script>
    <script type="text/javascript">
        $('#shortly').countdown({ until: shortly,
            onExpiry: liftOff, layout: "{ps} seconds to go"
        });

        $(document).ready(function () {
            shortly = new Date();
            shortly.setSeconds(shortly.getSeconds() + 5.5);
            $('#shortly').countdown('change', { until: shortly });
        });

        function liftOff() {
            // refresh the page  
            window.location = window.location;
        }   

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <span id="shortly"></span>
    </form>
</body>
</html>

我在 Visual Studio 的 Scriptsmap 中有 jquery.countdown.js。样式表“jquery.countdown.css”也在项目中。

不知道问题可能是什么。我是 jquery 的新手,正在努力学习它。

【问题讨论】:

    标签: asp.net jquery timer countdown


    【解决方案1】:

    我不熟悉这个倒计时插件,但是,尝试移动部件

        $('#shortly').countdown({ until: shortly,
            onExpiry: liftOff, layout: "{ps} seconds to go"
        });
    

    进入传递给$(document).ready的函数,替换$('#shortly').countdown('change', { until: shortly });

    因为否则shortly var 在您尝试使用它时不会被初始化。

    【讨论】:

      【解决方案2】:

      windowwindow.location 的 liftOff 函数有错误

      function liftOff() {
          // refresh the page  
          window.location = window.location;
      } 
      

      【讨论】:

      • 啊,没注意到,谢谢。但是我的计时器仍然没有显示。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多