Location.href

JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax

location.href

Description

The href property of the Location object represents the entire URL string for the current page displayed in the browser.

In the following fictitious Web address:

http://www.mcp.com:80/foo?something#foobar

the href value would be the entire URL address.

Example

An example of how to get the href value is shown in Listing 7.383.

Listing 7.383 Example of the href Property
<html>
<head>
<title> Using the href property of the Location object</title>
</head>
<body>

<script language="JavaScript">
<!-- Hide
function show(){
     document.location.href ="http://www.mcp.com:80/foo?something#foobar";
}
							 // End Hide ---> </script> <form name="form1"> ...

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.