Area hostProperty
Area Object
Definition and Usage
The host property can set or return the href attribute value'shostname:portpart.
Syntax
areaObject.host=hostname:port
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the host property
Tips and Notes
Note:If the port part is not specified in the URL, or the port is 80 (the default value), some browsers will not display the port part.
Example
Example
The following example can return the hostname and port of the "Venus" area:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
</head>
<body>
<img src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>Venus area's hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>Note:</b> If the port part of the URL is not specified, or it is 80 (the default), some browsers will not display the port part.</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
</head>
<body>
<img src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>Venus area's hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>Note:</b> If the port part of the URL is not specified, or it is 80 (the default), some browsers will not display the port part.</p>
</body>
</html>
The output of the above example:
Venus area's hostname:port: www.example.com
Try it Yourself »
Area Object Other Extensions