Base hrefProperty

Base 对象参考手册Base Object

Definition and Usage

The href attribute sets or returns the base URL for all links in a page.

Syntax

baseObject.href=URL


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the href attribute


Examples

Examples

The following example can return the base URL of the page:

<html>
<head>
<base id="htmldom" href="../jsref/index.html">
</head>
<body>

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

</body>
</html>

The output of the above example:

Base URL is: https://www.example.com/jsref/

Try it Yourself »


Base 对象参考手册Base Object Other Extensions