This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

href

Summary

Sets or retrieves the entire URL as a string.

Property of dom/Locationdom/Location

Syntax

var url = location.href;
location.href = url;

Return Value

Returns an object of type StringString

The URL of the document.

Examples

This example shows a URL list. The user is taken to the URL selected from the options, if the selection is different from the list’s default value.

<select onchange="window.location.href=this.options[this.selectedIndex].value">
<option value="http://www.microsoft.com/ie">Internet Explorer</option>
<option value="http://www.microsoft.com">Microsoft Home</option>
<option value="http://msdn.microsoft.com">Developer Network</option>
</select>

Attributions