HTML DOM title Attribute
Definition and Usage
The title attribute sets or returns the (advisory) title of an element.
Syntax:
object.title=title
Example 1
This example demonstrates two methods to obtain the title attribute of the <body> element:
<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>
Example 2
This example returns the title of a certain area in the image map:
<html>
<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):
<script type="text/javascript">
x=document.getElementById('venus')
document.write(x.title
)
</script>
</p>
</body>
</html>