searchParams readonly property of the URL interface returns a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL.

注意: 此特征可用于 Web 工作者 .

句法

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.
实时标准 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: