Area search Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Area

Description

The search property sets or gets the querystring part (URL after the question mark ?) of the href attribute value.

Set the search property with the following Values

Value Description
querystring Sets the search part of a URL

Return Value

A String, representing the querystring part of the URL, including the question mark (?)

The following code shows how to Return the querystring 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" target="_blank" shape="circle" coords="125,60,10" alt="Venus" href="venus.htm?id=searchtest">
</map>//from  w ww.j a v  a2 s .co  m

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

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

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

</body>
</html>

Related Tutorials