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://www.dbjr.com.cn/";
document.frames("refreshAlarm").src="http://www.dbjr.com.cn/";
注意區(qū)別:document.all.refreshAlarm 或 document.frames("refreshAlarm") 得到的是http://www.dbjr.com.cn/頁(yè)面中那個(gè)iframe標(biāo)簽,所以對(duì)src屬性操作有用。
document.frames("refreshAlarm").document得到iframe里面的內(nèi)容,也就是"http://www.dbjr.com.cn/"中的內(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遞歸打印Document層次關(guān)系實(shí)例分析
這篇文章主要介紹了Javascript遞歸打印Document層次關(guān)系的方法,實(shí)例分析了javascript中Document的層次關(guān)系,需要的朋友可以參考下2015-05-05uniapp使用mui-player插件播放m3u8/flv視頻流示例代碼
在小程序里播放視頻是很常見(jiàn)的功能,下面這篇文章主要給大家介紹了關(guān)于uniapp使用mui-player插件播放m3u8/flv視頻流的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06開(kāi)發(fā) Internet Explorer 右鍵功能表(ContextMenu)
本篇介紹如何開(kāi)發(fā) Internet Explorer 右鍵功能表(ContextMenu),以 0rz.tw 縮短網(wǎng)址列為范例2013-07-07原生JS實(shí)現(xiàn)圖片網(wǎng)格式漸顯、漸隱效果
這篇文章主要介紹了原生JS實(shí)現(xiàn)圖片網(wǎng)格式漸顯、漸隱效果,需要的朋友可以參考下2017-06-06使用開(kāi)源工具制作網(wǎng)頁(yè)驗(yàn)證碼的方法
這篇文章主要介紹了使用開(kāi)源工具制作網(wǎng)頁(yè)驗(yàn)證碼的方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-10-10一文詳解JavaScript中的URL和URLSearchParams
URL,稱(chēng)為統(tǒng)一資源定位器,指互聯(lián)網(wǎng)上能找到資源定位的字符串,而URLSearchParams對(duì)象是專(zhuān)門(mén)用于處理url網(wǎng)址信息中的查詢(xún)字符串,本文就來(lái)帶大家深入了解一下二者的使用2023-05-05