How to refresh the current page? With js you can do anything.
1, reload method, this method forces the browser to refresh the current page.
Syntax: location.reload([bForceGet])
Parameters: bForceGet, optional parameter, default is false, retrieve the current page from the client cache. true, then use the GET method to fetch the latest page from the server, which is equivalent to the client clicking F5 ("Refresh")
2, replace method, which replaces the item currently cached in the history (client) by specifying the URL , so after using the replace method, you cannot access the replaced URL through "forward" and "back".
Syntax: location.replace(URL)
Usually use: location.reload() or history.go(0) to do it.
This method is similar to the client pressing F5 to refresh the page, so when the page method="post", a "webpage expired" prompt will appear.
Because of Session’s security protection mechanism.
When the location.reload() method is called, the aspx page already exists in the server memory, so it must be IsPostback.
If there is such an application: The page needs to be reloaded, which means that the page is expected to be re-created on the server side, and the expectation is Not IsPostback.
Here, location.replace() can complete this task. The replaced page is regenerated on the server every time.
Code: location.replace(location.href);
Return and refresh the page:
location.replace(document.referrer);
document.referrer //URL of the previous page
Do not use history.go(- 1), or history.back(); to return and refresh the page. These two methods will not refresh the page.
Attachment:
Several methods of Javascript refreshing 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
Methods to automatically refresh the page:
1. The page automatically refreshes: add the following code to the
<meta http-equiv="refresh" content="20">
The 20 fingers refresh every 20 seconds Once the page.
2, the page automatically jumps: add the following code to the
<meta http-equiv="refresh" content="20;url=http://www.php.cn">
20 fingers will jump to the http://www.php.cn page after 20 seconds
3, the page automatically refreshes js version
<script language="JavaScript"> function myrefresh() { window.location.reload(); } setTimeout('myrefresh()',1000); //指定1秒刷新一次 </script>
4, JS refresh frame script statement
//刷新包含该框架的页面用 <script language=JavaScript> parent.location.reload(); </script> //子窗口刷新父窗口 <script language=JavaScript> self.opener.location.reload(); </script> ( 或 <a href="javascript:opener.location.reload()">刷新</a> ) //刷新另一个框架的页面用 <script language=JavaScript> parent.另一FrameID.location.reload(); </script>
If you want to refresh when closing the window or when opening the window, just call the following statement in
.<body onload="opener.location.reload()"> 开窗时刷新 <body onUnload="opener.location.reload()"> 关闭时刷新 <script language="javascript"> window.opener.document.location.reload() </script>
First, let’s look at a simple example:
The following takes three pages named frame.html, top.html, and bottom.html as an example to specifically explain how to do it.
frame.html consists of two pages: top (top.html) and bottom (bottom.html). The code is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> frame </TITLE> </HEAD> <frameset rows="50%,50%"> <frame name=top src="top.html"> <frame name=bottom src="bottom.html"> </frameset> </HTML>
Now assume that top.html (i.e., the page above) has seven buttons to implement bottom.html ( That is, to refresh the page below), you can use the following seven statements. It’s up to you which one is easier to use. The code of the
top.html page is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> top.html </TITLE> </HEAD> <BODY> <input type=button value="刷新1" onclick="window.parent.frames[1].location.reload()"><br> <input type=button value="刷新2" onclick="window.parent.frames.bottom.location.reload()"><br> <input type=button value="刷新3" onclick="window.parent.frames['bottom'].location.reload()"><br> <input type=button value="刷新4" onclick="window.parent.frames.item(1).location.reload()"><br> <input type=button value="刷新5" onclick="window.parent.frames.item('bottom').location.reload()"><br> <input type=button value="刷新6" onclick="window.parent.bottom.location.reload()"><br> <input type=button value="刷新7" onclick="window.parent['bottom'].location.reload()"><br> </BODY> </HTML>
The following is the source code of the bottom.html page. In order to prove that the page below has indeed been refreshed, a dialog box will pop up after the page is loaded.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> bottom.html </TITLE> </HEAD> <BODY onload="alert('我被加载了!')"> <h1 id="This-nbsp-is-nbsp-the-nbsp-content-nbsp-in-nbsp-bottom-html">This is the content in bottom.html.</h1> </BODY> </HTML>
Explain:
1.window指代的是当前页面,例如对于此例它指的是top.html页面。 2.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是framedemo.html。 3.frames是window对象,是一个数组。代表着该框架内所有子页面。 4.item是方法。返回数组里面的元素。 5.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。 附: Javascript刷新页面的几种方法: 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
2. Automatically refresh the page
1. Automatically refresh the page: Add the following code to the
<meta http-equiv="refresh" content="20">
Among them, 20 refers to refreshing the page every 20 seconds.
2. The page automatically jumps: add the following code to the area
20 of them will jump to the http://www.jb51.net page after 20 seconds
3. The page automatically refreshes the js version
<script language="JavaScript"> function myrefresh() { window.location.reload(); } setTimeout('myrefresh()',1000); //指定1秒刷新一次 </script>
3. Java is writing Servler, Action, etc. When executing a program, if you want to return to the page (such as opening the window, after the operation is completed, close the current page and refresh the parent page)
1 PrintWriter out = response.getWriter(); 2 out.write("<script type=\"text/javascript\">"); 3 ////子窗口刷新父窗口 4 out.write("self.opener.location.reload();"); 5 //关闭窗口 6 out.write("window.opener=null;"); 7 out.write("window.close();"); 8 out.write("</script>");
4. JS script statement to refresh the frame
1. How to refresh the page containing the frame with
<script language=JavaScript> parent.location.reload(); </script>
2. The child window refreshes the parent window
<script language=JavaScript> self.opener.location.reload(); </script>
3. How to refresh the page of another frame (the above example illustrates)
语句1. window.parent.frames[1].location.reload(); 语句2. window.parent.frames.bottom.location.reload(); 语句3. window.parent.frames["bottom"].location.reload(); 语句4. window.parent.frames.item(1).location.reload(); 语句5. window.parent.frames.item('bottom').location.reload(); 语句6. window.parent.bottom.location.reload(); 语句7. window.parent['bottom'].location.reload();
4. If you want to refresh when the window is closed or you want to refresh when the window is opened, in Just call the following statement in
.Refresh when opening the window
Refresh when closing
<script language="javascript"> window.opener.document.location.reload() </script>
For more js refresh page related articles, please pay attention to the PHP Chinese website!

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
