There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.
Close

Processing...
This may take a few seconds.

location

Syntax

location: [["](url)["]|reload] [every (time)] [after (time)];

This command does a hard redirect of the current page to the specified URL. Optional double-quotes surround the URL.

To refresh the current page, use the option reload (version 2.15.0+), as shown here:

#refreshButton:click {
location: reload;
}

The reload option follows the same behaviour as JavaScript's location.reload().

The following example redirects the current page to an outside URL:

#mdnLink:click {
    location: "https://developer.mozilla.org/en-US/docs/Web/";
}

Note: It runs a Javascript document.location.href on the current document, or tries to do it on the target document if the target is an iframe.

For more details on document.location.href, see here:

https://developer.mozilla.org/en-US/docs/Web/API/Document/location

location

Click the button below for an 80s throwback.

#locationButton:click {
    location: "https://www.youtube.com/watch?v=btPJPFnesV4";
}
<p>Click the button below for an 80s throwback.</p>

<button id="locationButton">Click me</button>