THE WORLD'S LARGEST WEB DEVELOPER SITE

Location search Property

❮ Location Object

Example

Return the querystring part of a URL. Assume that the current URL is https://www.w3schools.com/submit.htm?email=someone@example.com:

var x = location.search;

The result of x will be:

?email=someone@example.com

Definition and Usage

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

The querystring part is the part of the URL after the question mark (?). This is often used for parameter passing.


Browser Support

Property
search Yes Yes Yes Yes Yes

Syntax

Return the search property:

location.search

Set the search property:

location.search = querystring

Property Values

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

Technical Details

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

❮ Location Object