国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 幫助中心 > 正文

js刷新頁面location.reload()用法詳解

2024-07-09 22:42:29
字體:
來源:轉載
供稿:網友

本文介紹了js刷新頁面函數location.reload()的用法,有關js location.reload()函數的例子,有需要的朋友參考下。

在javascript編程中,多使用location.reload實現頁面刷新。

例子:

window.location.href=window.location.href; window.location.reload; 

經測試,這兩句在某些情況下可以代替location.reload(true);

而不會出現重試對話框達到刷新的效果

在js中實現刷新頁面的方法有很多種,在js中有一個location.reload()函數,它就可以實現我們想要的功能。

window.location.reload(true) //瀏覽器重新從服務器請求資源,在http請求頭中不會包含緩存標記。

例1,刷新當前頁面

<script> window.location.reload(); </script>

例2,JS實現刷新iframe的方法

用iframe的name屬性定位 

<input type="button" name="Button" value="Button" οnclick="document.frames('ifrmname').location.reload()"> 或 <input type="button" name="Button" value="Button" οnclick="document.all.ifrmname.document.location.reload()">

例3,首先,定義一個iframe 

<iframe method="post" id ="IFrameName" src="aa.htm" ></iframe>

aa.htm頁面的內容: 

 <input type ="button" value ="刷新" onclick ="aa()"/> function aa() {//parent.location.replace(parent.location.href);//服務器端重新創建頁面 parent.document.location.reload();//相當于F5 //window.location.href(parent.location.href);//iframe內容重定向 }

注意:

window.location.reload;

刷新時如果提交數據的動作,則會出現對話框!

解決辦法:

window.location.href=window.location.href; window.location.reload;

刷新父窗口:

window.opener.location.href=window.opener.location.href; window.opener.location.reload(); 

這種寫法不會顯示對話框。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網之家。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云霄县| 花莲县| 西贡区| 罗平县| 安达市| 琼结县| 南岸区| 安龙县| 沙河市| 三河市| 塔河县| 乌审旗| 赞皇县| 彩票| 中宁县| 陆良县| 许昌市| 永安市| 天峻县| 南乐县| 扶风县| 鱼台县| 伊金霍洛旗| 安阳县| 阳江市| 格尔木市| 翁牛特旗| 济阳县| 九台市| 湖南省| 大厂| 泸水县| 谷城县| 巴彦淖尔市| 高碑店市| 钟山县| 紫阳县| 白城市| 灵石县| 宜春市| 新民市|