W3Schools.com

Location search Property

Location Object Reference Location Object

Definition and Usage

The search property returns the query portion of a URL, including the question mark (?).

Syntax

location.search


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The search property is supported in all major browsers.


Example

Example

Return the query portion of a URL. Assume that the current URL is http://www.example.com/submit.htm?email=someone@example.com:

<script type="text/javascript">

document.write(location.search);

</script>

The output of the code above will be:

?email=someone@example.com


Location Object Reference Location Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE