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

js實現(xiàn)刷新iframe的方法匯總

 更新時間:2015年04月27日 14:33:17   投稿:hebedich  
這里給大家匯總了一些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)容了,希望大家能夠喜歡。

相關文章

最新評論