href Property

Internet Development Index

Sets or retrieves the entire URL as a string.

Syntax

location.href [ = sURL ]

Possible Values

sURLString that specifies or receives a URL.

The property is read/write. The property has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

Example

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>

Standards Information

This property is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 Non-Microsoft link.

Applies To

location

See Also

navigate