TUTORIAL前端与浏览器FETCHED

Base href 属性

Base href 属性 Base 对象 定义和用法 href 属性可设置或返回页面中所有链接的基准 URL。 语法 baseObject.href=URL 浏览器支持 所有主要浏览器都支持 href 属性 实例 实例 下面的例子可返回页面的基准 URL:: <html> <head> <base id='htmldom' h..

更新于 2026/7/16

教程详情页默认 noindex。

Base href 属性

Base 对象参考手册 Base 对象

定义和用法

href 属性可设置或返回页面中所有链接的基准 URL。

语法

baseObject.href=URL


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 href 属性


实例

实例

下面的例子可返回页面的基准 URL::

<html>
<head>
<base id="htmldom" href="https://www.runoob.com/jsref/">
</head>
<body>

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

</body>
</html>

以上实例输出结果:

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

尝试一下 »


Base 对象参考手册 Base 对象