1) html的實現
<
head
>
<!-- 以下方式只是刷新不跳轉到其他頁面 -->
<
meta
http-equiv="refresh" content="10">
<!-- 以下方式定時轉到其他頁面 -->
<
meta
http-equiv="refresh" content="5;url=hello.html">
</
head
>
2) javascript的實現
<script language=
"javascript"
type=
"text/javascript"
>
// 以下方式直接跳轉
window.location.href=
'hello.html'
;
// 以下方式定時跳轉
setTimeout(
"javascript:location.href='hello.html'"
, 5000);
</script>
<
span
id="totalSecond">5</
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>
其他
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
這幾個都可以刷新
window.location.reload();刷新
window.location.href=window.location.href;刷新
window.close();關閉窗口,不彈出系統提示,直接關閉
window.close()相當於self屬性是當前窗口
window.parent.close()是parent屬性是當前窗口或框架的框架組
頁面實現跳轉的九種方法實例:
<html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title>navigate</title>
< script language="javascript">
setTimeout('window.navigate("top.html");',2000);
setTimeout('window.document.location.href="top.html";',2000);
setTimeout('window.document.location="top.html";',2000);
setTimeout('window.location.href="top.html";',2000);
setTimeout('window.location="top.html";',2000);
setTimeout('document.location.href="top.html";',2000);
setTimeout('document.location="top.html";',2000);
setTimeout('location.href="top.html";',2000);
setTimeout('location.replace("top.html")',2000);
//window對象
//document對象
//location對象
//href屬性
//1.window.document.location.href
//2.window.document.location
//3.window.location.href
//4.window.location
//5.document.location.href
//6.document.location
//7.location.href
//8.window.navigate
//9.location.replace
//只要使用location方法,和任意的window對象,location對象,href屬性連用,都可以頁面的跳轉////
< /script>
< /head>
< body>
頁面將在2秒后跳轉
< /body>
< /html>
解釋:
location是個對象,比如本頁的document.location和window.location的屬性有
location.hostname = community.csdn.net
location.href = http://community.csdn.net/Expert/topic/4033/4033372.xml?temp=2.695864E-02
location.host = community.csdn.net
location.hash =
location.port =
location.pathname = /Expert/topic/4033/4033372.xml
location.search = ?temp=2.695864E-02
location.protocol = http:
可見href是location的屬性,類別是string。
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
這幾個都可以刷新
window.location.reload();刷新
window.location.href=window.location.href;刷新
window.close();關閉窗口,不彈出系統提示,直接關閉
window.close()相當於self屬性是當前窗口
window.parent.close()是parent屬性是當前窗口或框架的框架組
頁面實現跳轉的九種方法實例:
<html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title>navigate</title>
< script language="javascript">
setTimeout('window.navigate("top.html");',2000);
setTimeout('window.document.location.href="top.html";',2000);
setTimeout('window.document.location="top.html";',2000);
setTimeout('window.location.href="top.html";',2000);
setTimeout('window.location="top.html";',2000);
setTimeout('document.location.href="top.html";',2000);
setTimeout('document.location="top.html";',2000);
setTimeout('location.href="top.html";',2000);
setTimeout('location.replace("top.html")',2000);
//window對象
//document對象
//location對象
//href屬性
//1.window.document.location.href
//2.window.document.location
//3.window.location.href
//4.window.location
//5.document.location.href
//6.document.location
//7.location.href
//8.window.navigate
//9.location.replace
//只要使用location方法,和任意的window對象,location對象,href屬性連用,都可以頁面的跳轉////
< /script>
< /head>
< body>
頁面將在2秒后跳轉
< /body>
< /html>
解釋:
location是個對象,比如本頁的document.location和window.location的屬性有
location.hostname = community.csdn.net
location.href = http://community.csdn.net/Expert/topic/4033/4033372.xml?temp=2.695864E-02
location.host = community.csdn.net
location.hash =
location.port =
location.pathname = /Expert/topic/4033/4033372.xml
location.search = ?temp=2.695864E-02
location.protocol = http:
可見href是location的屬性,類別是string。