Javascript examples for DOM HTML Element:Anchor
The search property sets or gets the querystring part of the href attribute value.
The querystring is after the question mark ?.
Value | Description |
---|---|
querystring | Sets the search part of a URL |
A String, representing the querystring part of the URL, including the question mark (?)
The following code shows how to Return the querystring part of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" target="_blank" href="http://www.example.com:80/test.htm?id=searchtest">Example link</a></p> <button onclick="myFunction()">get the querystring part of the link above</button> <p id="demo"></p> <script> function myFunction() {//from w ww .j a v a2 s .co m var v = document.getElementById("myAnchor").search; document.getElementById("demo").innerHTML = v; } </script> </body> </html>