diff options
Diffstat (limited to 'files/uk/web/api/urlsearchparams/index.html')
-rw-r--r-- | files/uk/web/api/urlsearchparams/index.html | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/files/uk/web/api/urlsearchparams/index.html b/files/uk/web/api/urlsearchparams/index.html new file mode 100644 index 0000000000..78ab36b8e8 --- /dev/null +++ b/files/uk/web/api/urlsearchparams/index.html @@ -0,0 +1,171 @@ +--- +title: URLSearchParams +slug: Web/API/URLSearchParams +translation_of: Web/API/URLSearchParams +--- +<p>{{ApiRef("URL API")}}</p> + +<p><strong><code>URLSearchParams</code></strong> інтерфейс визначає корисні методи для роботи з довгими текстовими URL.</p> + +<p>Об'єктна реалізація <code>URLSearchParams</code> може використовуватись напряму в {{jsxref("Statements/for...of", "for...of")}} структурі, замість {{domxref('URLSearchParams.entries()', 'entries()')}}: <code>for (var p of mySearchParams)</code> що еквівалентно до <code>for (var p of mySearchParams.entries())</code>.</p> + +<h2 id="Конструктор">Конструктор</h2> + +<dl> + <dt>{{domxref("URLSearchParams.URLSearchParams", 'URLSearchParams()')}}</dt> + <dd>Конструктор вертає <code>URLSearchParams</code> об'єкт.</dd> +</dl> + +<h2 id="Properties">Properties</h2> + +<p><em>This interface doesn't inherit any property.</em></p> + +<h2 id="Методи">Методи</h2> + +<p><em>Інтерфейс на наслідує ніяких методів</em></p> + +<dl> + <dt>{{domxref("URLSearchParams.append()")}}</dt> + <dd>Appends a specified key/value pair as a new search parameter.</dd> + <dt>{{domxref("URLSearchParams.delete()")}}</dt> + <dd>Deletes the given search parameter, and its associated value, from the list of all search parameters.</dd> + <dt>{{domxref("URLSearchParams.entries()")}}</dt> + <dd>Returns an {{jsxref("Iteration_protocols","iterator")}} allowing to go through all key/value pairs contained in this object.</dd> + <dt>{{domxref("URLSearchParams.get()")}}</dt> + <dd>Returns the first value associated to the given search parameter.</dd> + <dt>{{domxref("URLSearchParams.getAll()")}}</dt> + <dd>Returns all the values association with a given search parameter.</dd> + <dt>{{domxref("URLSearchParams.has()")}}</dt> + <dd>Returns a {{jsxref("Boolean")}} indicating if such a search parameter exists.</dd> + <dt>{{domxref("URLSearchParams.keys()")}}</dt> + <dd>Returns an {{jsxref("Iteration_protocols", "iterator")}} allowing to go through all <strong>keys </strong>of the key/value pairs contained in this object.</dd> + <dt>{{domxref("URLSearchParams.set()")}}</dt> + <dd>Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.</dd> + <dt>{{domxref("URLSearchParams.toString()")}}</dt> + <dd>Returns a string containg a query string suitable for use in a URL.</dd> + <dt>{{domxref("URLSearchParams.values()")}}</dt> + <dd>Returns an {{jsxref("Iteration_protocols", "iterator")}} allowing to go through all <strong>values </strong>of the key/value pairs contained in this object.</dd> +</dl> + +<h2 id="Example">Example</h2> + +<pre class="brush: js notranslate">var paramsString = "q=URLUtils.searchParams&topic=api" +var searchParams = new URLSearchParams(paramsString); + +//Iterate the search parameters. +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" +</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('URL', '#urlsearchparams', "URLSearchParams")}}</td> + <td>{{Spec2('URL')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatChrome(49)}}</td> + <td>{{CompatGeckoDesktop("29.0")}}</td> + <td>{{CompatNo}}</td> + <td>36</td> + <td>{{CompatNo}}</td> + </tr> + <tr> + <td><code>entries()</code>, <code>keys()</code>, <code>values()</code>, and support of <code>for...of</code></td> + <td>{{CompatChrome(49)}}</td> + <td>{{CompatGeckoDesktop("44.0")}}</td> + <td>{{CompatNo}}</td> + <td>36</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Android Webview</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(49)}}</td> + <td>{{CompatGeckoMobile("29.0")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(49)}}</td> + </tr> + <tr> + <td><code>entries()</code>, <code>keys()</code>, <code>values()</code>, and support of <code>for...of</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(49)}}</td> + <td>{{CompatGeckoMobile("44.0")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(49)}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li>Other URL-related interfaces: {{domxref("URL")}}, {{domxref("URLUtils")}}.</li> + <li><a href="https://developers.google.com/web/updates/2016/01/urlsearchparams?hl=en">Google Developers: Easy URL manipulation with URLSearchParams</a></li> +</ul> + +<dl> +</dl> |