In our daily work, during the editing process ofJavaScript, 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
Example 2, JS method to refresh iframe
Use the nameattribute of iframePositioning
或
Example 3, first, define the content of an iframe
aa.htm page:
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!