本文实例讲述了JavaScript实现定时页面跳转功能。分享给大家供大家参考,具体如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Test</title><script type="text/javascript" language="javascript" ><!--var time = 8; //时间,秒function Redirect(){window.location = "http://www.vevb.com/";}var i = 0;function dis(){document.all.s.innerHTML = "还剩" + (time - i) + "秒";i++;}timer=setInterval('dis()', 1000);//显示时间timer=setTimeout('Redirect()',time * 1000); //跳转//--></script></head><body><span id="s"></span></body></html>
希望本文所述对大家JavaScript程序设计有所帮助。
新闻热点
疑难解答