Latest web development tutorials
 

Location search Property

< Location Object

Example

Return the querystring part of a URL. Assume that the current URL is http://www.w3ii.com/[email protected]:

var x = location.search;

The result of x will be:


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