Latest web development tutorials

HTML DOM Base href attribute

Base Object Reference Base Object

Definition and Usage

href property sets or returns a reference page URL for all links.

grammar

baseObject.href=URL


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support href attribute


Examples

Examples

The following example returns the base URL of the page ::

<html>
<head>
<base id="htmldom" href="http://www.w3cschool.cc/jsref/">
</head>
<body>

<p>Base URL is:
<script>
document.write(document.getElementById("htmldom").href);
</script>
</p>

</body>
</html>

Examples of the above output:

Base URL is: http://www.w3cschool.cc/jsref/

try it"


Base Object Reference Base Object