码迷,mamicode.com
首页 > 其他好文 > 详细

显示几秒内跳转

时间:2016-06-27 19:44:12      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
</head>
<body>
    <span id="totalSecond">2</span>
    <script language="javascript" type="text/javascript">
        var second = document.getElementById(totalSecond).textContent;

        if (navigator.appName.indexOf("Explorer") > -1) {
            second = document.getElementById(totalSecond).innerText;
        } else {
            second = document.getElementById(totalSecond).textContent;
        }

        setInterval("redirect()", 1000);
        function redirect() {
            if (second < 1) {
                location.href = http://www.baidu.com;
            } else {
                if (navigator.appName.indexOf("Explorer") > -1) {
                    document.getElementById(totalSecond).innerText = second--;
                } else {
                    document.getElementById(totalSecond).textContent = second--;
                }
            }
        }
    </script>
</body>
</html>

 

显示几秒内跳转

标签:

原文地址:http://www.cnblogs.com/hhls/p/5620745.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!