How to refresh the page in JavaScript

藏色散人
Release: 2023-01-07 11:41:53
Original
2886 people have browsed it

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.

How to refresh the page in JavaScript

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

Method 2: replace() method

replace() 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>
Copy after login

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!

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!