Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

URLUtils.searchParams

URLUtils.searchParams 属性是一个 URLSearchParams 实例,通过它可以获取到当前 URL 上的所有参数的值。

示例

var anchor = document.createElement("a");
anchor.href = "https://developer.mozilla.org/en-US/search?q=URLUtils.searchParams&topic=api"
var searchParams = anchor.searchParams;

searchParams.has("topic") === true; // true
searchParams.get("topic") === "api"; // true
searchParams.getAll("topic"); // ["api"]
searchParams.get("foo") === ""; // true
searchParams.append("topic", "webdev");
searchParams.toString(); // "q=URLUtils.searchParams&topic=api&topic=webdev"
searchParams.delete("topic");
searchParams.toString(); // "q=URLUtils.searchParams"
anchor.href; // "https://developer.mozilla.org/en-US/search?q=URLUtils.searchParams"

规范

Specification Status Comment
URL Living Standard Initial definition.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 未实现 29.0 (29.0) 未实现 未实现 未实现
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 29.0 (29.0) 未实现 未实现 未实现

相关链接

文档标签和贡献者

 此页面的贡献者: teoli, ziyunfei
 最后编辑者: ziyunfei,