--- title: URLSearchParams slug: Web/API/URLSearchParams translation_of: Web/API/URLSearchParams ---
{{ApiRef("URL API")}}
La interfaz URLSearchParams
define métodos útiles para trabajar con los parámetros de búsqueda de una URL.
Un objeto implementando URLSearchParams
puede directamente ser usado en una {{jsxref("Statements/for...of", "for...of")}} estructura, en lugar de {{domxref('URLSearchParams.entries()', 'entries()')}}: for (var p of mySearchParams)
la cual es equivalente a for (var p of mySearchParams.entries())
.
URLSearchParams
.Esta interfaz no hereda ninguna propiedad.
Esta interfaz no hereda ningún método.
var paramsString = "q=URLUtils.searchParams&topic=api" var searchParams = new URLSearchParams(paramsString); //Itera los parámetros de búsqueda. for (let p of searchParams) { console.log(p); } 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.delete("topic"); searchParams.toString(); // "q=URLUtils.searchParams"
Especificaciones | Estado | Comentario |
---|---|---|
{{SpecName('URL', '#urlsearchparams', "URLSearchParams")}} | {{Spec2('URL')}} | Definición Inicial. |
{{ CompatibilityTable() }}
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Soporte básico | {{CompatChrome(49)}} | {{CompatGeckoDesktop("29.0")}} | {{CompatNo}} | 36 | 10.1 |
entries() , keys() , values() , and support of for...of |
{{CompatChrome(49)}} | {{CompatGeckoDesktop("44.0")}} | {{CompatNo}} | 36 | {{CompatUnknown}} |
USVString for constructor init object |
{{CompatVersionUnknown}} | {{CompatGeckoDesktop("53.0")}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
Record for constructor init object |
{{CompatNo}} | {{CompatGeckoDesktop("54.0")}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} |
Característica | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Soporte básico | {{CompatChrome(49)}} | {{CompatChrome(49)}} | {{CompatGeckoMobile("29.0")}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatNo}} |
entries() , keys() , values() , and support of for...of |
{{CompatChrome(49)}} | {{CompatChrome(49)}} | {{CompatGeckoMobile("44.0")}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatNo}} |
USVString for constructor init object |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("53.0")}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} |
Record for constructor init object |
{{CompatUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile("54.0")}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} |