X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Location search Property

Location Object Reference Location Object

Example

Return the querystring part of a URL. Assume that the current URL is http://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

Internet Explorer Firefox Opera Google Chrome Safari

The search property is supported in all major browsers.


Syntax

Return the search property:

location.search

Set the search property:

location.search=querystring

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

Return Value

Type Description
String The querystring part of a URL, including the question mark (?)


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook