zoukankan      html  css  js  c++  java
  • setInterval()设置页面5,4,3,2,1秒后跳转

    <!DOCTYPE html>
    <html>
    
        <head>
            <meta charset="UTF-8">
            <title>页面跳转</title>
            <script type="text/javascript">
                window.onload = function() {
                    var time = 5;
                    var svalue = document.getElementById("span");
                    var timer = setInterval(function() {
                        svalue.innerHTML = time--;
                        if(time == 0) {
                            clearInterval(timer);//清楚定时操作
                            location.href = "http://www.baidu.com";
                        }
                    }, 1000);
                }
            </script>
        </head>
    
        <body>
            恭喜你注册成功,<span style="color: red;" id="span">5</span>秒后自动跳转。 如不跳转请单击
            <a href="http://www.baudi.com">跳转</a>
        </body>
    
    </html>
    window.onload:页面加载事件,当html启动时自动加载。
    setInterval(code,millisec[,"lang"])
     
    clearInterval();
    
    
  • 相关阅读:
    PHP入门
    requests中text,content,json之间的区别
    有关pip报错的问题

    pycharm操作
    python selenium 相关操作
    python tkinter菜单
    初识Go
    Python _easygui详细版
    easygui _1
  • 原文地址:https://www.cnblogs.com/asndxj/p/9801924.html
Copyright © 2011-2022 走看看