Javascript examples for DOM HTML Element:Area
The pathname property sets or gets the pathname part of the href attribute value.
Set the pathname property with the following Values
Value | Description |
---|---|
path | Sets the pathname of a URL |
A String, representing the pathname of the URL
The following code shows how to Return the pathname of the URL for a specific area in an image-map:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap"> <map name="myMap"> <area id="myId" target="_blank" shape="circle" coords="125,60,10" alt="Venus" href="http://www.example.com/test.htm"> </map>/* w w w .j a v a 2 s . c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myId").pathname; document.getElementById("demo").innerHTML = x; } </script> </body> </html>