Area target Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Area

Description

The target property sets or gets the value of the target attribute of an area.

The target attribute sets where to open the linked document.

Set the target property to the following value

Value Description
_blankOpen the linked document in a new window
_self Open the linked document in the same frame as it was clicked (this is default)
_parent Open the linked document in the parent frameset
_top Open the linked document in the full body of the window
framename Open the linked document in a named frame

Return Value

A String, representing where to open the linked document

The following code shows how to Change the target 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>//from w  w w  . j  a  v a2s  .c  o  m

<button onclick="myFunction()">set the value of the target attribute</button>

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

<script>
function myFunction() {
    document.getElementById("myId").target = "_blank";
    document.getElementById("demo").innerHTML = "The value of the target attribute was set.";
}
</script>

</body>
</html>

Related Tutorials