从后面的代码传递参数时,倒计时器不工作

时间:2015-01-08 05:08:31

标签: c#

这是我的javascript for timer

    <script>
    function test(time) {
        var seconds = time;
    }
    function secondPassed() {

        var MINUTES_IN_AN_HOUR = 60;
        var SECONDS_IN_A_MINUTE = 60;


        var totalMinutes = (seconds / SECONDS_IN_A_MINUTE);
        var minutes = Math.floor(totalMinutes % MINUTES_IN_AN_HOUR);
        var hours = Math.floor(totalMinutes / MINUTES_IN_AN_HOUR);
        var remainingSeconds =(seconds % SECONDS_IN_A_MINUTE);


        document.getElementById("countdown").innerHTML =hours +":"+ minutes + ":" + remainingSeconds;
        if (seconds == 0) {
            clearInterval(countdownTimer);
            document.getElementById("countdown").innerHTML = "Buzz Buzz";           
        }
        else {
            seconds--;
        }
    }

    var countdownTimer = setInterval('secondPassed()', 1000);
</script>``

这是我的aspx coading

    <div id="countdown" class="timer">
    </div>

这是我背后的代码

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int time = 1 * 3600;
            string script = String.Format("test({0})", time);
            this.Page.ClientScript.RegisterStartupScript(this.GetType(),
            "testFunction", script, true);
        }
    }

当我正在运行此im时出现错误以及如何在倒计时为0时重定向到页面

0 个答案:

没有答案