html頭添加代碼html
<meta http-equiv="refresh" content="3; url=http://www.baidu.com/" />
js實現緩存
1、最外層top跳轉頁面,適合用於iframe框架集服務器
top.window.location.href("http://www.baidu.com");
============================================================================================框架
2、window.location.href和window.location.replace的區別ui
1.window.location.href=「url」:改變url地址;url
2.window.location.replace(「url」):將地址替換成新url,該方法經過指定URL替換當前緩存在歷史裏(客戶端)的項目,
所以當使用replace方法以後,你不能經過「前進」和「後 退」來訪問已經被替換的URL,這個特色對於作一些過渡頁面很是有用!spa
3、強制頁面刷新 .net
1.window.location.reload():強制刷新頁面,從服務器從新請求! code
============================================================================================xml
4、window.location.reload();
頁面實現跳轉和刷新:
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屬性是當前窗口或框架的框架組
頁面實現跳轉的九種方法實例:
1 setTimeout('window.navigate("top.html");',2000); 2 setTimeout('window.document.location.href="top.html";',2000); 3 setTimeout('window.document.location="top.html";',2000); 4 setTimeout('window.location.href="top.html";',2000); 5 setTimeout('window.location="top.html";',2000); 6 setTimeout('document.location.href="top.html";',2000); 7 setTimeout('document.location="top.html";',2000); 8 setTimeout('location.href="top.html";',2000); 9 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屬性連用,均可以頁面的跳轉
解釋:
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。