Share via

HREF Attribute | href Property

Note: This documentation is preliminary and is subject to change.

Sets or retrieves the destination URL or anchor point.


Scripting [ sURL = ] object.href

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.


HREF attributes on anchors can be used to jump to bookmarks or any object's identification attribute.

If HREF is present but is blank (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  As of Microsoft Internet Explorer 6 Service Pack 1 (SP1), browsing a local machine from the Internet zone is not allowed. For example, if an Internet site contains a link to a local file, Internet Explorer 6 SP1 and greater displays a blank page when a user clicks on the link. Previous versions of Windows Internet Explorer followed the link to the local file.


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 World Wide Web link and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To