Home >Web Front-end >Front-end Q&A >How to refresh the page in JavaScript
Methods for refreshing the page in JavaScript: 1. Refresh the current document through the reload() method; 2. Replace the current document with a new document through the replace() method.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
How to refresh the page in JavaScript?
js Refresh the current page
js Refresh the current page method:
Method 1: reload() method
## The #reload() method is used to refresh the current document. The reload() method is similar to the refresh page button on your browser.location.reload();Method 2: replace() methodreplace() method can replace the current document with a new document. .
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <script> function replaceDoc() { window.location.replace("http://www.runoob.com") } </script> </head> <body> <input type="button" value="载入新文档替换当前页面" onclick="replaceDoc()"> </body> </html>Recommended study: "
javascript Advanced Tutorial"
The above is the detailed content of How to refresh the page in JavaScript. For more information, please follow other related articles on the PHP Chinese website!