日期:2014-05-17  浏览次数:20487 次

js执行顺序的问题
情况一
<head>
    <title>登录失败</title>
   
</head>
<body>
    <center>
        <img src="images/loading.gif" />
        <h1 style="color: RosyBrown">
            修改失败了。。。。<span id="faileInfor"></span>秒后 跳转回修改界面</h1>
        <img src="images/sorry.jpg" />
    </center>
</body>
 <script type="text/javascript">
       
        var i = 5;
        var myspan = document.getElementById("faileInfor");
        function chang() { 
            myspan.innerText = i;
            if (--i == 0) {
                window.clearInterval(mytime);
                window.location.href = "Modify.aspx?";
            }
        }

        // 启用一个定时器
        var mytime = window.setInterval("chang()", 1000);
    </script>
</html>
情况二
<head>
    <title>登录失败</title>
    <script type="text/javascript">
       
        var i = 5;
        var myspan = document.getElementById("faileInfor");
        function chang() { 
            myspan.innerText = i;
            if (--i == 0) {
                window.clearInterval(mytime);
                window.location.href = "Modify.aspx?";
            }
        }

        // 启用一个定时器
        var mytime = window.setInterval("chang()", 1000);
    </script>
</head>
<body>
    <center>
        <img src="images/loading.gif" />
        <h1 style="color: RosyBrown">
            修改失败了。。。。<span id="faileInfor"></span>秒后 跳转回修改界面</h1>
        <img src="images/sorry.jpg" />