Skip to Content

Location Reload: How to Reload a Page in JavaScript

This tutorial will teach you how to reload a page with the Location.reload() method, available in JavaScript's built-in window.location object and Location API.

The Syntax


forceReload is an optional boolean argument, determining whether or not the reloaded page will contain fresh content or will contain a cached version from the browser.

A value of true reloads a fresh page from the server:


A value of false, or an omitted forceReload parameter, will reload a version of the page cached by the browser:


Assign to an HTML Element with an onClick Event

You can bind this event to any HTML element on a page using an onClick event handler:

<button type="button" onClick="window.location.reload();">Refresh</button>

Browser Support

The Location.reload() method in JavaScript is widely available in all modern browsers.

Created: September 03, 2022


There are no comments yet. Start the conversation!

Add A Comment

Comment Etiquette: Wrap code in a <code> and </code>. Please keep comments on-topic, do not post spam, keep the conversation constructive, and be nice to each other.