Location.search

JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax

location.search

Description

The search property of the Location object represents the query portion of the URL, including the preceding question mark.

In the following fictitious Web address:

http://www.mcp.com:80/foo?something#foobar

the search value would be the ?something portion.

Example

Listing 7.389 shows how to use the search property. When the button is clicked, the show function displays the value of the search property in the text box.

Listing 7.389 Example of the search Property
 <html> <head> <title> Using the search property of the Location object</title> </head> <body> <script language="JavaScript"> <!-- Hide // function displays the search property ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.