Window location.search attribute

Definition and usage

search The attribute returns the URL's query string part, including the question mark (?).

search The attribute can also be used to set the query string.

Comment

The query string part is the part after the question mark (?) in the URL.

Query strings are used to pass parameters.

Example

Return the URL's query string part:

let query = location.search;

Try it yourself

Syntax

Return search attribute:

location.search

Set search attribute:

location.search = querystring

Attribute value

Value Description
querystring URL's query string part.

Return value

Type Description
String

URL's query string part, including the question mark (?).

Browserunderstøttelse

Alle browsere understøtter location.search

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support