URL.searchParams

URL 인터페이스의 searchParams 읽기 전용 속성은 URL 내의 GET 디코딩 된 쿼리 매개변수에 접근할 수 있는 URLSearchParams 객체를 반환합니다.

주의: 이 기능은 Web Worker에서 사용할 수 있습니다.

구문

const urlSearchParams = url.searchParams

URLSearchParams 객체.

예제

페이지의 URL을 https://example.com/?name=Jonathan%20Smith&age=18로 가정했을 때, nameage 매개변수는 다음과 같이 가져올 수 있습니다.

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

명세

Specification Status Comment
URL
The definition of 'searchParams' in that specification.
Living Standard Initial definition.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
searchParamsChrome Full support 51Edge Full support 17Firefox Full support 29IE No support NoOpera Full support 38Safari Full support 10WebView Android Full support 51Chrome Android Full support 51Firefox Android Full support 29Opera Android Full support 41Safari iOS Full support 10Samsung Internet Android Full support 5.0

Legend

Full support  
Full support
No support  
No support