Location search Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Location

Description

The search property sets or gets the querystring part of a URL, including the question mark (?).

The querystring part is the part of the URL after the question mark (?).

Set the search property with the following Values

Value Type Description
querystring String Sets the search part of the URL

Return Value

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

The following code shows how to Return the querystring part of a URL.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {/*from   w w w. ja  va  2  s . c  o m*/
    var x = location.search;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials