The target
property sets or gets the target attribute of an area.
The target attribute specifies where to open the linked document.
Its possible values are listed in the following table:
Value | Description |
---|---|
_blank | Open the link in a new window |
_self | Open the link in the same frame as it was clicked. Default. |
_parent | Open the link in the parent frameset |
_top | Open the link in the full body of the window |
framename | Open the link in a named frame |
Get the target of a specific area in an image-map:
var x = document.getElementById("myArea").target;
Click the button to display the value of the target attribute for the myArea
area in the image-map.
<!DOCTYPE html> <html> <body> <img src="image1.png" width="100" height="100" usemap="#myFlagMap"> <map name="myFlagMap"> <area id="myArea" shape="circle" coords="50,50,40" alt="Target" href="https://www.java2s.com" target="_self"> </map>/*w w w. ja v a 2 s . c om*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myArea").target; document.getElementById("demo").innerHTML = x; } </script> </body> </html>