searchParams
readonly property of the
URL
interface returns a
URLSearchParams
object allowing access to the
GET
decoded query arguments contained in the URL.
const urlSearchParams = url.searchParams
A
URLSearchParams
对象。
If the URL of your page is
https://example.com/?name=Jonathan%20Smith&age=18
you could parse out the
名称
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
| 规范 | 状态 | 注释 |
|---|---|---|
|
URL
The definition of 'searchParams' in that specification. |
实时标准 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
searchParams
|
Chrome 51 | Edge 17 | Firefox 29 | IE No | Opera 38 | Safari 10 | WebView Android 51 | Chrome Android 51 | Firefox Android 29 | Opera Android 41 | Safari iOS 10 | Samsung Internet Android 5.0 |
完整支持
不支持