Light ModeDark ModeReset dark mode. Falls back to OS dark mode setting.


No results for 'undefined'

Blog Posts

No results for 'undefined'
Powered by Algolia

Vanilla JavaScript, How to Reload a Page With the Window Reload Event

Dec 29, 20171 min readJavaScriptViews:

To reload a webpage with JavaScript we need to use the Window Reload Event.

Reload page with a single line of JavaScript:

Paste this code into your browser Console and hit enter.

Cool, but perhaps not so practical? Let’s try something else.

Reload page with a button click event:

<button onclick="reloadPage()">Reload page</button>
Add this to your HTML markup.

The window reload event function:

function reloadPage() {
Add this to your JavaScript file.

See it in action by clicking this button:

What are you waiting for?! Click on it!

All the code on CodePen.

Note: the window reload event doesn’t work inside the CodePen editor, but you can test it out in CodePen’s debug mode.


Has this been helpful?
Let me know in the comments!

Or share it with your friends :-)

© 2019 - TechStacker
Powered byGatsbyGithubNetlify