window.location

JavaScript1.0+, JScript1.0+ Nav2+, IE3+, Opera3+ Syntax

							window.location

Description

The location property of the Window object returns the current URL of the document in the window.

Example

Listing 7.549 pops up an alert box that contains the URL of the current window.

Listing 7.549 Using the location Property of the Window Object
<script language="JavaScript">
<!-- Hide

// Display the current URL in an alert box
alert(window.location);

// End hide --->
</script>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.