Sets or retrieves the destination URL or anchor point.
Syntax
HTML | <ELEMENT HREF
= sURL... >
|
---|
Scripting | object.href [ = sURL ] |
---|
Possible Values
sURL | String that
specifies or receives the URL or anchor point. |
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.
Remarks
HREF attributes on anchors can be used to jump to bookmarks or any object's identification attribute.
If HREF is present but is blank (in other words HREF="" OR HREF=), executing the link could possibly display the directory containing the current page, or it could generate an error depending on other elements on the web page and the server environment.
When an anchor is specified, the link to that address is represented by the text between the opening and closing anchor tags.
For more information on standard Internet protocols such as ftp, http, and mailto, see Predefined Protocols.
Note Microsoft® Internet Explorer 6 Service Pack 1 (SP1) no longer allows browsing a local machine from the Internet zone. For instance, if an Internet site contains a link to a local file, Internet Explorer 6 SP1 displays a blank page when a user clicks on the link. Previous versions of Internet Explorer followed the link to the local file.
Example
This example function returns the href property of the current page location.
function getHref()
{
return document.location.href;
}
Standards Information
This property is defined in
HTML 3.2 and
is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To