js實現(xiàn)刷新iframe的方法匯總
javascript實現(xiàn)刷新iframe的方法的總結,現(xiàn)在假設存在下面這樣一個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()">
第三種方法:當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)在當內(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.dbjr.com.cn/";
document.frames("refreshAlarm").src="http://www.dbjr.com.cn/";
注意區(qū)別:document.all.refreshAlarm 或 document.frames("refreshAlarm") 得到的是http://www.dbjr.com.cn/頁面中那個iframe標簽,所以對src屬性操作有用。
document.frames("refreshAlarm").document得到iframe里面的內(nèi)容,也就是"http://www.dbjr.com.cn/"中的內(nèi)容。
javascript(js)自動刷新頁面的實現(xiàn)方法總結:
間隔10秒刷新一次,在頁面的head標簽中加入下面的代碼段:
<meta http-equiv="refresh"content="10;url=跳轉的頁面或者是需要刷新的頁面URL地址">
定時刷新頁面(間隔2秒刷新一下頁面):
<script language="javascript">
setTimeout("location.href='url'",2000);//url是要刷新的頁面URL地址
</script>
直接刷新頁面事件:
<script language="javascript">
window.location.reload(true);
//如需刷新iframe,則只需把window替換為響應的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)容了,希望大家能夠喜歡。
相關文章
Javascript遞歸打印Document層次關系實例分析
這篇文章主要介紹了Javascript遞歸打印Document層次關系的方法,實例分析了javascript中Document的層次關系,需要的朋友可以參考下2015-05-05uniapp使用mui-player插件播放m3u8/flv視頻流示例代碼
在小程序里播放視頻是很常見的功能,下面這篇文章主要給大家介紹了關于uniapp使用mui-player插件播放m3u8/flv視頻流的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-06-06開發(fā) Internet Explorer 右鍵功能表(ContextMenu)
本篇介紹如何開發(fā) Internet Explorer 右鍵功能表(ContextMenu),以 0rz.tw 縮短網(wǎng)址列為范例2013-07-07原生JS實現(xiàn)圖片網(wǎng)格式漸顯、漸隱效果
這篇文章主要介紹了原生JS實現(xiàn)圖片網(wǎng)格式漸顯、漸隱效果,需要的朋友可以參考下2017-06-06一文詳解JavaScript中的URL和URLSearchParams
URL,稱為統(tǒng)一資源定位器,指互聯(lián)網(wǎng)上能找到資源定位的字符串,而URLSearchParams對象是專門用于處理url網(wǎng)址信息中的查詢字符串,本文就來帶大家深入了解一下二者的使用2023-05-05