1.使用setTimeout函数实现定时跳转(如下代码要写在body区域内)
<script type="text/javascript"> //3秒钟之后跳转到指定的页面 setTimeout(window.location.href='http://www.baidu.com',3); </script>
<!--5秒钟后跳转到指定的页面--> <meta http-equiv="refresh" content="5;url=http://www.baidu.com" />
<!doctype html> <head> <meta charset=utf-8" /> <title>js定时跳转页面的方法</title> </head> <body> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%3E%20%0Avar%20t%3D10%3B%2F%2F%E8%AE%BE%E5%AE%9A%E8%B7%B3%E8%BD%AC%E7%9A%84%E6%97%B6%E9%97%B4%20%0AsetInterval(%22refer()%22%2C1000)%3B%20%2F%2F%E5%90%AF%E5%8A%A81%E7%A7%92%E5%AE%9A%E6%97%B6%20%0Afunction%20refer()%7B%20%0Aif(t%3D%3D0)%7B%20%0Alocation%3D%22http%3A%2F%2Fwww.baidu.com%22%3B%20%2F%2F%23%E8%AE%BE%E5%AE%9A%E8%B7%B3%E8%BD%AC%E7%9A%84%E9%93%BE%E6%8E%A5%E5%9C%B0%E5%9D%80%20%0A%7D%20%0Adocument.getElementById('show').innerHTML%3D%22%22%2Bt%2B%22%E7%A7%92%E5%90%8E%E8%B7%B3%E8%BD%AC%E5%88%B0%E7%99%BE%E5%BA%A6%22%3B%20%2F%2F%20%E6%98%BE%E7%A4%BA%E5%80%92%E8%AE%A1%E6%97%B6%20%0At--%3B%20%2F%2F%20%E8%AE%A1%E6%95%B0%E5%99%A8%E9%80%92%E5%87%8F%20%0A%2F%2F%E6%9C%AC%E6%96%87%E8%BD%AC%E8%87%AA%EF%BC%9A%20%0A%7D%20%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" /> <span id="show"></span> </body> </html>
必须登录才可以留言哦!