Auto refresh current page with regular intervals using JS

/ By Arjun / Published on April 8, 2017

To refresh or reload active or current page using JavaScript, you can use the location.reload() and setTimeout() methods. The reload() method does the same as the reload button in your browser.The setTimeout() method calls evaluates an expression after a specified number of milliseconds.

By default, the reload() method reloads the page from the cache, but you can force it to reload the page from the server by setting the forceGet parameter to true: location.reload(true).

Example script to Auto refresh current page

Source code of a sample HTML page that reloads page with 3 seconds regular intervals.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
Stephen Komu
Stephen Komu
2 years ago

Ajax has this function that auto updates contents once maybe the database is updated. My question is, does javascript es6 contain the same functionality?

Would love your thoughts, please comment.x