From 38a18236aca758a3c29963a8654ab7c5d84dd9ca Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sun, 27 Feb 2022 15:00:03 +0900 Subject: 2021/11/08 時点の英語版に同期 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/node/isdefaultnamespace/index.md | 96 ++++++++++++++++------- 1 file changed, 66 insertions(+), 30 deletions(-) (limited to 'files/ja/web/api/node/isdefaultnamespace/index.md') diff --git a/files/ja/web/api/node/isdefaultnamespace/index.md b/files/ja/web/api/node/isdefaultnamespace/index.md index 018e6562cc..44f1b3acec 100644 --- a/files/ja/web/api/node/isdefaultnamespace/index.md +++ b/files/ja/web/api/node/isdefaultnamespace/index.md @@ -1,35 +1,71 @@ --- -title: Node.isDefaultNamespace +title: Node.isDefaultNamespace() slug: Web/API/Node/isDefaultNamespace tags: - - DOM - - Gecko DOM Reference - - Namespaces - - Node + - メソッド + - リファレンス +browser-compat: api.Node.isDefaultNamespace translation_of: Web/API/Node/isDefaultNamespace --- -
- {{ApiRef}}
-

概要

-

isDefaultNamespace は、引数としてネームスペース URI を受け取り、ネームスペースが指定されたノードのデフォルトのネームスペースである場合に true を返します。そうでない場合は false を返します。

-

構文

-
result = node.isDefaultNamespace(namespaceURI)
-
- -

-
var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-var el = document.getElementsByTagNameNS(XULNS, 'textbox')[0];
-
-alert(el.isDefaultNamespace(XULNS)); // true
-

仕様書

- -

関連情報

- +{{APIRef("DOM")}} + +**`isDefaultNamespace()`** は {{domxref("Node")}} インターフェイスのメソッドで、名前空間 URI を引数として受け取ります。 +その名前空間がこのノードの既定の名前空間である場合は `true` を返し、そうでない場合は `false` を返します。 + +> **Note:** 既定の名前空間は、 HTML 要素では常に `""` です。 SVG 要素では、 `xmlns` 属性で設定されます。 + +## 構文 + +```js +isDefaultNamespace(namespaceURI); +``` + +### 引数 + +- `namespaceURI` + - : 要素の検査対象となる名前空間を表す文字列です。 + > **Note:** `namespaceURI` は省略可能ではありませんが、 `null` に設定することはできます。 + +### 返値 + +`true` または `false` の値を持つ論理値で、引数が既定の名前空間であるかどうかを示します。 + +## 例 + +```html +"" が <output> の既定の名前空間であるか: 未検査
+"http://www.w3.org/2000/svg" が <output> の既定の名前空間であるか: 未検査
+"" が <svg> の既定の名前空間であるか: 未検査
+"http://www.w3.org/2000/svg" が <svg> の既定の名前空間であるか: 未検査
+ + +``` + +```js +const button = document.getElementsByTagName('button')[0]; +button.addEventListener("click", function () { + const aHtmlElt = document.getElementsByTagName('output')[0]; + const aSvgElt = document.getElementsByTagName('svg')[0]; + + const result = document.getElementsByTagName('output'); + result[0].value = aHtmlElt.isDefaultNamespace(""); // true + result[1].value = aHtmlElt.isDefaultNamespace("http://www.w3.org/2000/svg"); // false + result[2].value = aSvgElt.isDefaultNamespace(""); // true + result[3].value = aSvgElt.isDefaultNamespace("http://www.w3.org/2000/svg"); // false +}); +``` + +{{ EmbedLiveSample('Example','100%',130) }} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- {{domxref("Node.lookupNamespaceURI")}} +- {{domxref("Node.lookupPrefix")}} -- cgit v1.2.3-54-g00ecf