Usage of JavaScript refresh page location.reload()

黄舟
Release: 2017-11-16 14:02:45
Original
4544 people have browsed it

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;
Copy after login

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

Copy after login

Example 2, JS method to refresh iframe
Use the nameattribute of iframePositioning

Copy after login

Example 3, first, define the content of an iframe

Copy after login

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内容重定向 }
Copy after login

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;
Copy after login

Refresh the parent window:

window.opener.location.href=window.opener.location.href; window.opener.location.reload();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!