js實現(xiàn)刷新iframe的方法匯總
javascript實現(xiàn)刷新iframe的方法的總結(jié),現(xiàn)在假設(shè)存在下面這樣一個iframe,則刷新該iframe的N種方法有:
<iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>
第一種方法:用iframe的name屬性定位
<input type="button" name="Button" value="Button" onclick="document.frames('ifrmname').location.reload()">
或者
<input type="button" name="Button" value="Button" onclick="document.all.ifrmname.document.location.reload()">
第二種方法:用iframe的id屬性定位
<input type="button" name="Button" value="Button" onclick="ifrmid.window.location.reload()">
第三種方法:當(dāng)iframe的src為其它網(wǎng)站地址(即跨域操作時)
<input type="button" name="Button" value="Button" onclick="window.open(document.all.ifrmname.src,'ifrmname','')">
父頁面中存在兩個iframe,一個iframe中是一個鏈接列表,其中的鏈接指向另一個iframe,用于顯示內(nèi)容?,F(xiàn)在當(dāng)內(nèi)容內(nèi)容添加后,在鏈接列表中添加了一條記錄,則需要刷新列表iframe。
在內(nèi)容iframe的提交js中使用parent.location.reload()將父頁面全部刷新,因為另一個iframe沒有默認的url,只能通過列表選擇,所以只顯示了列表iframe的內(nèi)容。
使用window.parent.frames["列表iframe名字"].location="列表url"即可進刷新列表iframe,而內(nèi)容iframe在提交后自己的刷新將不受影響。
document.frames("refreshAlarm").location.reload(true);
document.frames("refreshAlarm").document.location.reload(true);
document.frames("refreshAlarm").document.location="http://www.dhdzp.com/";
document.frames("refreshAlarm").src="http://www.dhdzp.com/";
注意區(qū)別:document.all.refreshAlarm 或 document.frames("refreshAlarm") 得到的是http://www.dhdzp.com/頁面中那個iframe標(biāo)簽,所以對src屬性操作有用。
document.frames("refreshAlarm").document得到iframe里面的內(nèi)容,也就是"http://www.dhdzp.com/"中的內(nèi)容。
javascript(js)自動刷新頁面的實現(xiàn)方法總結(jié):
間隔10秒刷新一次,在頁面的head標(biāo)簽中加入下面的代碼段:
<meta http-equiv="refresh"content="10;url=跳轉(zhuǎn)的頁面或者是需要刷新的頁面URL地址">
定時刷新頁面(間隔2秒刷新一下頁面):
<script language="javascript">
setTimeout("location.href='url'",2000);//url是要刷新的頁面URL地址
</script>
直接刷新頁面事件:
<script language="javascript">
window.location.reload(true);
//如需刷新iframe,則只需把window替換為響應(yīng)的iframe的name屬性值或ID屬性值
</script>
直接刷新頁面事件:
<script language=''javascript''>
window.navigate("本頁面url");
</script>
直接刷新頁面事件:
function abc(){
window.location.href="/blog/window.location.href";
setTimeout("abc()",10000);
}
刷新框架頁:
<script language="javascript">
top.leftFrm.location.reload();
parent.frmTop.location.reload();
</script>
以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。
相關(guān)文章
javascript解析json格式的數(shù)據(jù)方法詳解
這篇文章主要介紹了javascript解析json格式的數(shù)據(jù)方法詳解,文章通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
use jscript List Installed Software
use jscript List Installed Software...2007-06-06
javascript 三種方法實現(xiàn)獲得和設(shè)置以及移除元素屬性
獲得和設(shè)置以及移除元素屬性在操作dom的過程中會經(jīng)常遇到吧,為了提高工作的效率本文整理了一些快捷操作方法和大家一起分享,感興趣的朋友可以參考下哈2013-03-03

