js實(shí)現(xiàn)刷新iframe的方法匯總
javascript實(shí)現(xiàn)刷新iframe的方法的總結(jié),現(xiàn)在假設(shè)存在下面這樣一個(gè)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)站地址(即跨域操作時(shí))
<input type="button" name="Button" value="Button" onclick="window.open(document.all.ifrmname.src,'ifrmname','')">
父頁(yè)面中存在兩個(gè)iframe,一個(gè)iframe中是一個(gè)鏈接列表,其中的鏈接指向另一個(gè)iframe,用于顯示內(nèi)容。現(xiàn)在當(dāng)內(nèi)容內(nèi)容添加后,在鏈接列表中添加了一條記錄,則需要刷新列表iframe。
在內(nèi)容iframe的提交js中使用parent.location.reload()將父頁(yè)面全部刷新,因?yàn)榱硪粋€(gè)iframe沒(méi)有默認(rèn)的url,只能通過(guò)列表選擇,所以只顯示了列表iframe的內(nèi)容。
使用window.parent.frames["列表iframe名字"].location="列表url"即可進(jìn)刷新列表iframe,而內(nèi)容iframe在提交后自己的刷新將不受影響。
document.frames("refreshAlarm").location.reload(true);
document.frames("refreshAlarm").document.location.reload(true);
document.frames("refreshAlarm").document.location="http://m.fzitv.net/";
document.frames("refreshAlarm").src="http://m.fzitv.net/";
注意區(qū)別:document.all.refreshAlarm 或 document.frames("refreshAlarm") 得到的是http://m.fzitv.net/頁(yè)面中那個(gè)iframe標(biāo)簽,所以對(duì)src屬性操作有用。
document.frames("refreshAlarm").document得到iframe里面的內(nèi)容,也就是"http://m.fzitv.net/"中的內(nèi)容。
javascript(js)自動(dòng)刷新頁(yè)面的實(shí)現(xiàn)方法總結(jié):
間隔10秒刷新一次,在頁(yè)面的head標(biāo)簽中加入下面的代碼段:
<meta http-equiv="refresh"content="10;url=跳轉(zhuǎn)的頁(yè)面或者是需要刷新的頁(yè)面URL地址">
定時(shí)刷新頁(yè)面(間隔2秒刷新一下頁(yè)面):
<script language="javascript">
setTimeout("location.href='url'",2000);//url是要刷新的頁(yè)面URL地址
</script>
直接刷新頁(yè)面事件:
<script language="javascript">
window.location.reload(true);
//如需刷新iframe,則只需把window替換為響應(yīng)的iframe的name屬性值或ID屬性值
</script>
直接刷新頁(yè)面事件:
<script language=''javascript''>
window.navigate("本頁(yè)面url");
</script>
直接刷新頁(yè)面事件:
function abc(){
window.location.href="/blog/window.location.href";
setTimeout("abc()",10000);
}
刷新框架頁(yè):
<script language="javascript">
top.leftFrm.location.reload();
parent.frmTop.location.reload();
</script>
以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。
相關(guān)文章
javascript解析json格式的數(shù)據(jù)方法詳解
這篇文章主要介紹了javascript解析json格式的數(shù)據(jù)方法詳解,文章通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
JS實(shí)現(xiàn)的五級(jí)聯(lián)動(dòng)菜單效果完整實(shí)例
這篇文章主要介紹了JS實(shí)現(xiàn)的五級(jí)聯(lián)動(dòng)菜單效果,結(jié)合完整實(shí)例形式分析了js多級(jí)聯(lián)動(dòng)菜單的完整實(shí)現(xiàn)步驟,涉及JS數(shù)組遍歷、擴(kuò)展及元素節(jié)點(diǎn)操作相關(guān)技巧,需要的朋友可以參考下2017-02-02
js實(shí)現(xiàn)簡(jiǎn)易點(diǎn)擊切換顯示或隱藏
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡(jiǎn)易點(diǎn)擊切換顯示或隱藏,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11
use jscript List Installed Software
use jscript List Installed Software...2007-06-06
js canvas實(shí)現(xiàn)隨機(jī)粒子特效
這篇文章主要為大家詳細(xì)介紹了js canvas隨機(jī)粒子特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-04-04
javascript 三種方法實(shí)現(xiàn)獲得和設(shè)置以及移除元素屬性
獲得和設(shè)置以及移除元素屬性在操作dom的過(guò)程中會(huì)經(jīng)常遇到吧,為了提高工作的效率本文整理了一些快捷操作方法和大家一起分享,感興趣的朋友可以參考下哈2013-03-03
JavaScript實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果
這篇文章主要介紹了JavaScript實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下,希望對(duì)你的學(xué)習(xí)有所幫助2022-06-06
Promise對(duì)象all與race方法手寫(xiě)示例
這篇文章主要為大家介紹了Promise對(duì)象all與race方法手寫(xiě)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12

