Note: This feature is available in Web Workers.
The searchParams
read-only 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.
The searchParams
read-only property of the URL
interface returns a URLSearchParams
object allowing access to the GET
decoded query arguments contained in the URL.
A URLSearchParams
object.
const params = new URL("https://example.com/?name=Jonathan%20Smith&age=18") .searchParams; const name = params.get("name"); const age = parseInt(params.get("age")); console.log(`name: ${name}`); // name: Jonathan Smith console.log(`age: ${age}`); // age: 18
Specification |
---|
URL Standard # dom-url-searchparams |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | ||
searchParams |
51 | 17 | 29 | 38 | 10.1 | 51 | 29 | 41 | 10.3 | 5.0 | 51 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams