Home  >  Article  >  Web Front-end  >  Summary of methods for refreshing JS pages

Summary of methods for refreshing JS pages

黄舟
黄舟Original
2017-11-16 14:16:514279browse

We introduced the usage of JavaScript to refresh the page location.reload(). In fact, there are many ways to refresh the page in JS, and this is just one of them. So today we Let me take you to learn a summary of the method of refreshing the page with JS!

window.location.reload(), window.history.go(0) and document.execCommand(''Refresh''), these three methods are the fastest of. Others have obvious browser scroll bars.
Several ways to refresh the page using Javascript:
1 history.go(0)
Unless there are pages such as d13fc09fc3a61027bf4a1ae346cec7e0 that need to be interpreted on the server side to be generated code, otherwise read the data in the cache directly
No refresh
2 location.reload()
You need to reconnect to the server to read the new page (although the page is the same)
Refresh
3 location=location
To navigate in javascript, instead of calling a method of the window object, set its location.href property , the location attribute is supported by every browser. For example:

top

Back and forward after execution
4 location.assign(location)
Load the new HTML document specified by the URL. It is equivalent to a link that jumps to the specified url. The current page will be converted to the new page content. You can click Back to return to the previous page.
5 document.execCommand('Refresh')
6 window.navigate(location)

The window.navigate(sURL) method mentioned by MSDN is for IE and does not apply to FF , in the HTML DOM Window Object, the window.navigate method is not listed at all.
7 location.replace(location)
No back or forward after execution
Replace the current document by loading the document specified by the URL. This method is to replace the current window page, the two before and after The pages share a
window, so there is no back to return to the previous page
8 document.URL=location.href

Javascript Several methods to refresh the page:
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand ('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href

Method to automatically refresh the page: javascript automatically Detailed explanation of the method of refreshing the page
1. Automatically refresh the page: Add the following code to the 93f0f5c25f18dab9d176bd4f6de5d30e area

where 20 means to refresh the page every 20 seconds.

2. The page automatically jumps: add the following code to the 93f0f5c25f18dab9d176bd4f6de5d30e area

where 20 refers to jumping after 20 seconds Go to //m.sbmmt.com page

3. The page automatically refreshes the js version

c9b2223153d8e39163b0aa064e06fe9efunction myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次2cacc6d41bbb37262a98f745aa00fbf0

JS refresh frame The script statement

//如何刷新包含该框架的页面用 


//子窗口刷新父窗口
 www.jbxue.com
( 或 刷新 )

//如何刷新另一个框架的页面用 

If you want to refresh when the window is closed or you want to refresh when the window is opened, just call the following statement in 6c04bd5ca3fcae76e30b72ad730ca86d.

 开窗时刷新
 关闭时刷新

Summary:

This article describes the method of refreshing the page in JavaScript through examples, which mainly explains the more commonly used ones. There are several methods, friends can choose the method that suits them according to their own needs!

related suggestion:

Usage of JavaScript refresh page location.reload()


JS refresh page sum! Various JS refresh page codes!


JS refresh page method collection

The above is the detailed content of Summary of methods for refreshing JS pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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