In our daily work, during the editing process of JavaScript, we often need to use the JS function to refresh the page, so we will often use location.reload(). Today we will understand Use JavaScript to refresh the page location.reload()!
In JavaScript programming, location.reload is often used to refresh the page.
Example:
window.location.href=window.location.href; window.location.reload;
After testing, these two sentences can replace location.reload(true);
in some cases without a retry dialog box. The effect of refreshing
There are many ways to refresh the page in js. There is a location.reload() function in js, which can achieve the function we want.
window.location.reload(true) //The browser re-requests resources from the server, and the cache tag will not be included in the http request header.
Example 1, refresh the current page
<script> window.location.reload(); </script>
Example 2, JS method to refresh iframe
Use the name attribute of iframe Positioning
<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()">
Example 3, first, define the content of an iframe
<iframe method="post" id ="IFrameName" src="aa.htm" ></iframe>
aa.htm page:
<input type ="button" value ="刷新" onclick ="aa()"/> function aa() { (jquery中文网 www.jquerycn.cn 编辑整理) //parent.location.replace(parent.location.href);//服务器端重新创建页面 parent.document.location.reload();//相当于F5 //window.location.href(parent.location.href);//iframe内容重定向 }
Note:
window.location.reload;
The action of submitting data when refreshing , a dialog box will appear!
Solution:
window.location.href=window.location.href; window.location.reload;
Refresh the parent window:
window.opener.location.href=window.opener.location.href; window.opener.location.reload();
Summary:
This article is passed to The explanation of the example allows friends to more intuitively understand the usage of JS refresh page location.reload(). I hope it will be helpful to your work!
Related recommendations:
js refresh page method collection
JS refresh page sum! Multiple JS refresh page codes!
Several methods of JS refresh page
The above is the detailed content of Usage of JavaScript refresh page location.reload(). For more information, please follow other related articles on the PHP Chinese website!