Anchor search Property - Change the querystring part of a link: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Anchor search Property - Change the querystring part of a link:

Demo Code

ResultView the demo in separate window

<!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()">change the querystring part of the link above</button>

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

<script>
function myFunction() {// w  w  w .j  ava 2 s  .  c  o m
    document.getElementById("myAnchor").search = "somenewsearchvalue";
    document.getElementById("demo").innerHTML = "The querystring part was changed from 'searchtest' to 'somenewsearchvalue'.";
}
</script>

</body>
</html>

Related Tutorials