Search w3schools.com:

SHARE THIS PAGE

Location search Property

Location Object Reference Location Object

Definition and Usage

The search property returns the query portion of a URL, including the question mark (?).

Syntax

location.search


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The search property is supported in all major browsers.


Example

Example

Return the query portion of a URL. Assume that the current URL is http://www.example.com/submit.htm?email=someone@example.com:

<script>

document.write(location.search);

</script>

The output of the code above will be:

?email=someone@example.com


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]