JavaScript Reference/Javascript Properties/href
"href" Example
<source lang="javascript">
<html> <head> <base id="myBase"> <script language="JavaScript">
function function1() { document.all.myBase.href= "http://www.wbex.ru"; }
</script>
</head>
<body>
<a id="myAnchor" href="/index.htm" hreflang="en">www.wbex.ru site</a>
<button onclick="function1();">Change the base URL</button>
<button onclick="alert(myAnchor.href);">Anchor</button>
<button onclick="alert(location.href);">Location</button>
</body>
</html>
</source>
"href" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |<a> <area> | | |<base> <link> | | |location styleSheet | +----------------+--------------------------------------------------------------+
</source>
"href" Syntax and Note
<source lang="javascript">
Note: Read and write property. For the <a>, this property specifies the anchor point of the URL. <area>, and <link> elements,
For the <base> element, it establishes a default URL for
relative links.
For the location object, it specifies the entire URL.
For the styleSheet object, it specifies the URL of the linked style sheet.
Syntax:
document.getElementById("elementID").href = value document.all.elementID.href = value // IE only
</source>