asp.net/jquery - 倒数计时器不工作

发布于 2024-09-02 06:14:26 字数 1497 浏览 2 评论 0原文

这是完整的代码:

  <%@ 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 有点陌生,正在尝试学习它。

Here is the full code:

  <%@ 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>

I've got the jquery.countdown.js in the Scriptsmap of visual studio. Also the stylesheet "jquery.countdown.css" is in the project.

Don't have a clue about what the problem could be. I'm kind of new to jquery and trying to learn it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜心小果奶 2024-09-09 06:14:26

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

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

传递给 $(document).ready 的函数中,替换 $('#shortly').countdown(' Change', { Until: Soon });

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

I'm not familiar with this countdown plugin, but, try moving the part

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

into the function passed to $(document).ready, replacing $('#shortly').countdown('change', { until: shortly });

Because otherwise the shortly var is not initialized when you're trying to use it.

画骨成沙 2024-09-09 06:14:26

windowwindow.location 的 liftOff 函数出现错误

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

you have a error in liftOff function with windowwindow.location

function liftOff() {
    // refresh the page  
    window.location = window.location;
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文