Home > Web Front-end > JS Tutorial > body text

js refresh page location.reload() usage

高洛峰
Release: 2016-12-17 15:45:08
Original
2180 people have browsed it

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

After testing, these two sentences can replace location.reload(true);
in some cases without a retry dialog box to achieve the refresh effect

How to refresh the page in js There are many kinds. 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 does not include cache tags in the http request header.

Example 1, refresh the current page

Copy after login

Example 2, JS implementation of refreshing iframe method
Use the name attribute of iframe to position

Copy after login

Example 3, first, define an iframe

Copy after login

aa.htm page content:

 
function aa() { (php中文网 m.sbmmt.com 编辑整理)
//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;
If you submit data during refresh, a dialog box will appear!

Solution:

window.location.href=window.location.href; 
window.location.reload;
Copy after login
Copy after login

Refresh the parent window:

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


For more js refresh page location.reload() usage related articles, please pay attention to 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
Popular Tutorials
More>
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!