首页 > Web开发 > 详细

javascript倒计时 页面跳转

时间:2014-01-23 16:54:52      阅读:370      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<!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>Count</title> 
    </head> 
    <body> 
 
<div style="text-align: center " >Enter baidu in
<span id="totalSecond" style="text-align: center ;font-family: GulimChe;font-size: 100px;">5
</span>seconds </div> 
 
<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 < 0) 
        { 
            location.href = www.baidu.com; //go to baidu
        } else 
        { 
            if (navigator.appName.indexOf("Explorer") > -1) 
            { 
                document.getElementById(totalSecond).innerText = second--; 
            } else 
            { 
                document.getElementById(totalSecond).textContent = second--; 
            } 
        } 
    } 
</script> 
    </body> 
</html> 
bubuko.com,布布扣

javascript倒计时 页面跳转

原文:http://www.cnblogs.com/batter152/p/3530701.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!