From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/urlsearchparams/get/index.html | 71 +++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 files/ja/web/api/urlsearchparams/get/index.html (limited to 'files/ja/web/api/urlsearchparams/get/index.html') diff --git a/files/ja/web/api/urlsearchparams/get/index.html b/files/ja/web/api/urlsearchparams/get/index.html new file mode 100644 index 0000000000..241c9cda19 --- /dev/null +++ b/files/ja/web/api/urlsearchparams/get/index.html @@ -0,0 +1,71 @@ +--- +title: URLSearchParams.get() +slug: Web/API/URLSearchParams/get +tags: + - API + - Method + - URL API + - URLSearchParams + - get +translation_of: Web/API/URLSearchParams/get +--- +

{{ApiRef("URL API")}}

+ +

{{domxref("URLSearchParams")}} インターフェースの get() メソッドは、指定された検索パラメーターに関連付けられた最初の値を返します。

+ +

{{availableinworkers}}

+ +

構文

+ +
URLSearchParams.get(name)
+ +

パラメーター

+ +
+
name
+
返すパラメーターの名前。
+
+ +

戻り値

+ +

指定された検索パラメーターが見つかった場合、{{domxref("USVString")}}。 それ以外の場合、null

+ +

+ +

ページの URL が https://example.com/?name=Jonathan&age=18 の場合、次を使用して 'name' および 'age' のパラメーターを解析できます。

+ +
let params = new URLSearchParams(document.location.search.substring(1));
+let name = params.get("name"); // 文字列 "Jonathan" です。
+let age = parseInt(params.get("age"), 10); // 数値 18 です。
+
+ +

クエリー文字列に存在しないパラメーターを要求すると、null が返されます。

+ +
let address = params.get("address"); // null
+ +

仕様

+ + + + + + + + + + + + + + + + +
仕様状態コメント
{{SpecName('URL', '#dom-urlsearchparams-get', "get()")}}{{Spec2('URL')}}初期定義
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("api.URLSearchParams.get")}}

+
-- cgit v1.2.3-54-g00ecf