HTML DOM Body link 屬性
定義和用法
link 屬性可設置或者返回body 元素的link屬性值。
link 屬性指定了文檔中鏈接未被點擊訪問的顏色。
語法
設置link 屬性:
bodyObject.link="color"
返回link 屬性:
bodyObject.link
值 | 描述 |
---|---|
color | 指定链接颜色。查看完整的 CSS 颜色值 |
瀏覽器支持
所有主要瀏覽器都支持link 屬性
實例
實例
返回文檔中未被點擊鏈接,點擊鏈接,點擊訪問後的鏈接顏色:
<html>
<body id="w3s" link="blue" alink="green" vlink="red">
<p><a href="http://www.w3cschool.cc">W3CSchool.cc</a></p>
<p><a href="http://www.w3cschool.cc/html/">HTML Tutorial</a></p>
<script>
document.write("Link color is: ")
document.write(document.getElementById("w3s").link);
document.write("<br>Active link color is: ")
document.write(document.getElementById("w3s").aLink);
document.write("<br>Visited link color is: ")
document.write(document.getElementById("w3s").vLink);
</script>
</body>
</html>
<body id="w3s" link="blue" alink="green" vlink="red">
<p><a href="http://www.w3cschool.cc">W3CSchool.cc</a></p>
<p><a href="http://www.w3cschool.cc/html/">HTML Tutorial</a></p>
<script>
document.write("Link color is: ")
document.write(document.getElementById("w3s").link);
document.write("<br>Active link color is: ")
document.write(document.getElementById("w3s").aLink);
document.write("<br>Visited link color is: ")
document.write(document.getElementById("w3s").vLink);
</script>
</body>
</html>
嘗試一下»
Body對象