The searchParams
readonly property of the URL
interface returns a URLSearchParams
object allowing access to the GET
decoded query arguments contained in the URL.
Note: This feature is available in Web Workers.
Syntax
const urlSearchParams = url.searchParams
Value
A URLSearchParams
object.
Examples
If the URL of your page is https://example.com/?name=Jonathan%20Smith&age=18
you could parse out the name
and age
parameters using:
let params = (new URL(document.location)).searchParams;
let name = params.get('name'); // is the string "Jonathan Smith".
let age = parseInt(params.get('age')); // is the number 18
Specifications
Specification | Status | Comment |
URLThe definition of 'searchParams' in that specification. | Living Standard | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
searchParams
|
Chrome
Full support 51 |
Edge
Full support 17 |
Firefox
Full support 29 |
IE
No support No |
Opera
Full support 38 |
Safari
Full support 10 |
WebView Android
Full support 51 |
Chrome Android
Full support 51 |
Firefox Android
Full support 29 |
Opera Android
Full support 41 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
URL.searchParams by Mozilla Contributors is licensed under CC-BY-SA 2.5.