HTML5自动跳转页面的常用方法
HTML的实现
<head> <!-- 以下方式只是刷新不跳转到其他页面 --> <meta http-equiv="refresh" content="10"> <!-- 以下方式定时转到其他页面 --> <meta http-equiv="refresh" content="5;url=hello.html"> </head>
JavaScript的实现
<script language="javascript" type="text/javascript"> // 以下方式直接跳转 window.location.href='hello.html';
// 以下方式定时跳转 setTimeout("javascript:location.href='hello.html'", 5000); </script>
利用倒数动态提示
//非firfox
<span id="totalSecond">3</span> <script language="javascript" type="text/javascript"> var second = totalSecond.innerText; setInterval("reDirect()", 1000); function reDirect(){ totalSecond.innerText=--second; if(second<0) location.href='hello.html'; } </script>
//firfox<script language=
"javascript"
type=
"text/javascript"
>
var
second = document.getElementById(
'totalSecond'
).textContent;
setInterval(
"redirect()"
, 1000);
function
redirect()
{ document.getElementById(
'totalSecond'
).textContent = --second;
if
(second < 0) location.href =
'hello.html'
;
}
</script>
本博客来自于
http://www.cnblogs.com/283383765pw/
抄袭可耻
请支持原作者