.location

The .location method can be used to redirect or return information about the current location.

 

Redirect

To redirect assign the target page to the window.location() function, like so:

 

window.location = "https://www.motogp.com"; //note use of assignment, not parentheses

 

To redirect a page straight away:

 

Or to call from a function, which could then be used in a setInterval():

 

 

Return values

.location can also be used to return values:

Leave a Reply