元素對象
title 屬性設定或傳回元素的标題。
HTMLElementObject.title=title
所有主要浏覽器都支援 title 屬性
傳回 body 元素的 title屬性:
<html>
<body id="myid" title="mytitle">
<script>
var
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
傳回圖像中的區域地圖示題:
<body>
<img src ="planets.gif"
width="145" height="126"
alt="Planets"
usemap ="#planetmap">
<map name ="planetmap">
<area id="venus" shape="circle"
coords ="124,58,8"
title="Venus"
href ="venus.htm">
</map>
<p>Venus' advisory title (mouse over the Venus planet):
x=document.getElementById('venus')
document.write(x.title)
</p>