We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Переклад не закінчено. Будь ласка, допоможіть перекласти цю статтю з англійської.

URLSearchParams інтерфейс визначає корисні методи для роботи з довгими текстовими URL.

Об'єктна реалізація URLSearchParams може використовуватись напряму в for...of структурі, замість entries(): for (var p of mySearchParams) що еквівалентно до for (var p of mySearchParams.entries()).


Конструктор вертає URLSearchParams об'єкт.


This interface doesn't inherit any property.


Інтерфейс на наслідує ніяких методів

Appends a specified key/value pair as a new search parameter.
Deletes the given search parameter, and its associated value, from the list of all search parameters.
Returns an iterator allowing to go through all key/value pairs contained in this object.
Returns the first value associated to the given search parameter.
Returns all the values association with a given search parameter.
Returns a Boolean indicating if such a search parameter exists.
Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.
Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
Returns a string containg a query string suitable for use in a URL.
Returns an iterator allowing to go through all values of the key/value pairs contained in this object.


var paramsString = "q=URLUtils.searchParams&topic=api"
var searchParams = new URLSearchParams(paramsString);

//Iterate the search parameters.
for (let p of searchParams) {

searchParams.has("topic") === true; // true
searchParams.get("topic") === "api"; // true
searchParams.getAll("topic"); // ["api"]
searchParams.get("foo") === null; // true
searchParams.append("topic", "webdev");
searchParams.toString(); // "q=URLUtils.searchParams&topic=api&topic=webdev"
searchParams.set("topic", "More webdev");
searchParams.toString(); // "q=URLUtils.searchParams&topic=More+webdev"
searchParams.toString(); // "q=URLUtils.searchParams"


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

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 49 29.0 (29.0) No support 36 No support
entries(), keys(), values(), and support of for...of 49 44.0 (44.0) No support 36 No support
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 49 29.0 (29.0) No support ? No support 49
entries(), keys(), values(), and support of for...of No support 49 44.0 (44.0) No support ? No support 49

See also

Мітки документа й учасники

Зробили внесок у цю сторінку: akmil
Востаннє оновлена: akmil,