Location searchProperty
Location Object
Definition and Usage
The search property is a readable and writable string that sets or returns the query portion of the current URL (the part after the question mark ?).
Syntax
location.search
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the search property
Example
Example
Return the query portion of the URL. Assuming the current URL is http://www.example.com/submit.htm?email=someone@ example.com:
<script>
document.write(location.search);
</script>
document.write(location.search);
</script>
The above example output:
?email=someone@example.com
Location Object Other Extensions