Home >Web Front-end >JS Tutorial >How do I Refresh a Page in JavaScript?
Refresh a Page with JavaScript
In JavaScript, refreshing a web page can be accomplished using the location.reload() function. This function reloads the current page by requesting it from the server.
For instance, to refresh the page when an element with the ID "something" is clicked, you can use the following code:
$('#something').click(function() { location.reload(); });
Additionally, the reload() function accepts an optional parameter that, when set to true, forces the browser to reload the page from the server and bypass the cache. By default, this parameter is set to false and the page may reload from the browser's cache.
The above is the detailed content of How do I Refresh a Page in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!