Javascript DOM HTML Area search Property get

Introduction

The search property sets or gets the query string of the href attribute value.

The URL query string is after the question mark ?.

It is used for parameter passing.

Return the query string of the URL for a specific area in an image-map:

var x = document.getElementById("myArea").search;

Click the button to display the query string of the href attribute for the myArea area in the image-map.

View in separate window

<!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?id=searchtest">
</map>//from  www. j  a  va  2 s .  c  o m

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

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

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

</body>
</html>



PreviousNext

Related