HTML DOM Base href 屬性
定義和用法
href 屬性可設置或返回頁面中所有鏈接的基準URL。
語法
baseObject.href=URL
瀏覽器支持
所有主要瀏覽器都支持href 屬性
實例
實例
下面的例子可返回頁面的基準URL::
<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>
<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>
以上實例輸出結果:
Base URL is: http://www.w3cschool.cc/jsref/
嘗試一下»
Base對象