This article introduces threejs refresh current pagemethods:

  • reload()Method;
  • replace()Method;
  • Auto-refresh page;

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();

You can use the onclick event on a button:

<input type="button" onclick="javascript:location.reload();" value="刷新当前页面">

Click the button below to refresh the current page:

For more information about the reload() method, please refer to the documentation:https://www.example.com/jsref/met-loc-reload.html

Method 2: replace() method

The replace() methodCan replace the current document with a new document.

Example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function replaceDoc()
{
    window.location.replace("https://www.example.com")
}
</script>
</head>
<body>

<input type="button" value="Load a new document to replace the current page" onclick="replaceDoc()">

</body>
</html>

For more information about the replace() method, please refer to the documentation:https://www.example.com/jsref/met-loc-replace.html


Method 3: Auto-refresh page

Auto-refresh page: add the following code to the <head> area

<meta http-equiv="refresh" content="5">

Here, 5 means the page refreshes every 5 seconds.

Try it »