The JavaScript location reload() method is used to reload the current page. It takes an optional argument: a boolean value indicating whether to reload the page from the server (true) or from the cache (false). It does not return any value.
Here are some examples of how the reload() method can be used in JavaScript code:
- To reload the current page from the server, you can use the following code:
// reload the current page from the server
location.reload(true);
- To reload the current page from the cache, you can use the following code:
// reload the current page from the cache
location.reload(false);
- To reload the current page with the default behavior (reloading from the server if the page is outdated, otherwise from the cache), you can use the following code:
// reload the current page with the default behavior
location.reload();
Overall, the reload() method provides a convenient way to refresh the current page. It can be useful for tasks such as updating the page with the latest data or restoring the page to its initial state, or for other operations that require reloading the page.
Leave a Reply