HTML DOM title 屬性
定義和用法
title 屬性可設置或返回對元素的描述性短語。
語法
bodyObject.title=title
實例
下面的例子將展示設置 <body> 元素的 title 屬性的兩種方法:
<html> <body id="myid" title="mytitle"> <script type="text/javascript">x=document.getElementsByTagName('body')[0];
document.write("Body title: " +x.title
); document.write("<br />"); document.write("An alternate way: "); document.write(document.getElementById('myid').title
); </script> </body> </html>
輸出:
Body title: mytitle An alternate way: mytitle