Area origin Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Area

Description

The origin property returns the protocol, hostname and port number of the href attribute value.

This property is read-only.

Return Value

A String, representing the protocol (including ://), the domain name or IP address and port number (including the colon sign (:) of the URL.

The following code shows how to Return the protocol, hostname and port number of the URL for a specific area in an image-map:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap">

<map name="myMap">
  <area id="myId" shape="circle" coords="125,60,10" alt="Venus" href="venus.htm">
</map>//w w  w.j a  va 2s.  co  m

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myId").origin;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials