window.location object

The location object represents a webpage's location. It can be used to change webpages by assigning a URL to it in JavaScript. It has some other uses, most beyond this course (w3schools.com). See also window.location.reload().


Examples:

The code:

<button onclick="window.location='http://www.google.com'">Go to google</button>

<h1 onmouseover="alert('Get Lost Chump!');window.location='http://www.webhamster.com/'"
style="width:300px">
Don't touch me!
</h1>

...as it appears on the Page:

Don't touch me!



Back to Knowledge Dump