The querystring part is the part of the URL after the question mark (?).
The search
property sets or gets
the querystring part of a URL, including the question mark (?).
search |
Yes | Yes | Yes | Yes | Yes |
Return the search property.
var v = location.search
Set the search property.
location.search=querystring
Value | Type | Description |
---|---|---|
querystring | String | Set the search part of the URL |
A String type value representing the querystring part of a URL, including the question mark (?).
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w w w. j a v a 2 s. c o m-->
var x = location.search;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: