HTML DOM Body aLink 屬性
定義和用法
aLink 屬性可設置或者返回body 元素中alink 屬性的值。
alink 屬性指定了文檔鏈接點擊時的顏色(鏈接被點擊時)。
語法
設置aLink 屬性:
bodyObject.aLink="color"
返回aLink 屬性:
bodyObject.aLink
值 | 描述 |
---|---|
color | 指定了链接颜色。查看完整的 CSS 颜色值 |
瀏覽器支持
所有主要瀏覽器都支持aLink 屬性
實例
實例
返回頁面鏈接,鏈接點擊時,鏈接點擊後的顏色值:
<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對象