欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js刷新頁面location.reload()用法詳解

 更新時(shí)間:2019年12月09日 14:26:40   作者:大灰狼的小綿羊哥哥  
這篇文章主要介紹了js刷新頁面location.reload()用法詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

本文介紹了js刷新頁面函數(shù)location.reload()的用法,有關(guān)js location.reload()函數(shù)的例子,有需要的朋友參考下。

在javascript編程中,多使用location.reload實(shí)現(xiàn)頁面刷新。

例子:

window.location.href=window.location.href; 
window.location.reload; 

經(jīng)測試,這兩句在某些情況下可以代替location.reload(true);

而不會(huì)出現(xiàn)重試對話框達(dá)到刷新的效果

在js中實(shí)現(xiàn)刷新頁面的方法有很多種,在js中有一個(gè)location.reload()函數(shù),它就可以實(shí)現(xiàn)我們想要的功能。

window.location.reload(true) //瀏覽器重新從服務(wù)器請求資源,在http請求頭中不會(huì)包含緩存標(biāo)記。

例1,刷新當(dāng)前頁面

<script> 
window.location.reload(); 
</script>

例2,JS實(shí)現(xiàn)刷新iframe的方法

用iframe的name屬性定位 

<input type="button" name="Button" value="Button" οnclick="document.frames('ifrmname').location.reload()"> 
或 
<input type="button" name="Button" value="Button" οnclick="document.all.ifrmname.document.location.reload()">

例3,首先,定義一個(gè)iframe 

<iframe method="post" id ="IFrameName" src="aa.htm" ></iframe>

aa.htm頁面的內(nèi)容: 

 <input type ="button" value ="刷新" onclick ="aa()"/> 
function aa() {
//parent.location.replace(parent.location.href);//服務(wù)器端重新創(chuàng)建頁面 
parent.document.location.reload();//相當(dāng)于F5 
//window.location.href(parent.location.href);//iframe內(nèi)容重定向 
}

注意:

window.location.reload;

刷新時(shí)如果提交數(shù)據(jù)的動(dòng)作,則會(huì)出現(xiàn)對話框!

解決辦法:

window.location.href=window.location.href; 
window.location.reload;

刷新父窗口:

window.opener.location.href=window.opener.location.href; 
window.opener.location.reload(); 

這種寫法不會(huì)顯示對話框。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論