blob: 8c8b04009f14f6f3b82293a860340e01828c8e90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---
title: URL.searchParams
slug: Web/API/URL/searchParams
tags:
- API
- Property
- Read-only
- Reference
- URL
- URLSearchParameter
- URLSearchParams
- searchParams
translation_of: Web/API/URL/searchParams
---
<div>{{APIRef("URL API")}}</div>
<p><span class="seoSummary">{{domxref("URL")}} インターフェイスの <strong><code>searchParams</code></strong> 読み取り専用プロパティは、URL に含まれる GET デコードされたクエリー引数へのアクセスを可能にする {{domxref("URLSearchParams")}} オブジェクトを返します。</span></p>
<p>{{AvailableInWorkers}}</p>
<h2 id="Syntax" name="Syntax">構文</h2>
<pre class="syntaxbox">var urlSearchParams = URL.searchParams;</pre>
<h3 id="Value" name="Value">値</h3>
<p>{{domxref("URLSearchParams")}} オブジェクト。</p>
<h2 id="Examples" name="Examples">例</h2>
<p>ページの URL が <code>https://example.com/?name=Jonathan%20Smith&age=18</code> の場合、次を使用して 'name' および 'age' パラメーターを解析できます。</p>
<pre class="brush: js">let params = (new URL(document.location)).searchParams;
let name = params.get('name'); // 文字列 "Jonathan Smith" です。
let age = parseInt(params.get('age')); // 数値 18 です。</pre>
<h2 id="Specifications" name="Specifications">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様</th>
<th scope="col">状態</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('URL', '#dom-url-searchparams', 'searchParams')}}</td>
<td>{{Spec2('URL')}}</td>
<td>初期定義</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<p>{{Compat("api.URL.searchParams")}}</p>
|