From 362ba6775c2337ed3dc91d5320f7e891c3c74f99 Mon Sep 17 00:00:00 2001 From: MDN Date: Sat, 13 Mar 2021 00:26:44 +0000 Subject: [CRON] sync translated content --- files/es/_redirects.txt | 2 +- files/es/_wikihistory.json | 12 +-- files/es/web/api/document/getselection/index.html | 14 ++++ .../documentorshadowroot/getselection/index.html | 14 ---- files/fr/_redirects.txt | 4 +- files/fr/_wikihistory.json | 20 ++--- files/fr/web/api/document/getselection/index.html | 16 ++++ .../documentorshadowroot/getselection/index.html | 16 ---- files/ja/_redirects.txt | 2 +- files/ja/_wikihistory.json | 12 +-- files/ja/web/api/document/getselection/index.html | 88 ++++++++++++++++++++++ .../documentorshadowroot/getselection/index.html | 87 --------------------- files/ko/_redirects.txt | 2 +- files/ko/_wikihistory.json | 12 +-- files/ko/web/api/document/getselection/index.html | 10 +++ .../documentorshadowroot/getselection/index.html | 10 --- files/pt-br/_redirects.txt | 2 +- files/pt-br/_wikihistory.json | 12 +-- .../pt-br/web/api/document/getselection/index.html | 10 +++ .../documentorshadowroot/getselection/index.html | 10 --- files/ru/_redirects.txt | 2 +- files/ru/_wikihistory.json | 12 +-- files/ru/web/api/document/getselection/index.html | 10 +++ .../documentorshadowroot/getselection/index.html | 10 --- files/zh-cn/_redirects.txt | 2 +- files/zh-cn/_wikihistory.json | 12 +-- .../zh-cn/web/api/document/getselection/index.html | 76 +++++++++++++++++++ .../documentorshadowroot/getselection/index.html | 75 ------------------ 28 files changed, 278 insertions(+), 276 deletions(-) create mode 100644 files/es/web/api/document/getselection/index.html delete mode 100644 files/es/web/api/documentorshadowroot/getselection/index.html create mode 100644 files/fr/web/api/document/getselection/index.html delete mode 100644 files/fr/web/api/documentorshadowroot/getselection/index.html create mode 100644 files/ja/web/api/document/getselection/index.html delete mode 100644 files/ja/web/api/documentorshadowroot/getselection/index.html create mode 100644 files/ko/web/api/document/getselection/index.html delete mode 100644 files/ko/web/api/documentorshadowroot/getselection/index.html create mode 100644 files/pt-br/web/api/document/getselection/index.html delete mode 100644 files/pt-br/web/api/documentorshadowroot/getselection/index.html create mode 100644 files/ru/web/api/document/getselection/index.html delete mode 100644 files/ru/web/api/documentorshadowroot/getselection/index.html create mode 100644 files/zh-cn/web/api/document/getselection/index.html delete mode 100644 files/zh-cn/web/api/documentorshadowroot/getselection/index.html diff --git a/files/es/_redirects.txt b/files/es/_redirects.txt index 88824dfe79..61c4468834 100644 --- a/files/es/_redirects.txt +++ b/files/es/_redirects.txt @@ -1790,7 +1790,7 @@ /es/docs/Web/API/Document/abrir /es/docs/Web/API/Document/open /es/docs/Web/API/Document/async /es/docs/Web/API/XMLDocument/async /es/docs/Web/API/Document/crearAtributo /es/docs/Web/API/Document/createAttribute -/es/docs/Web/API/Document/getSelection /es/docs/Web/API/DocumentOrShadowRoot/getSelection +/es/docs/Web/API/DocumentOrShadowRoot/getSelection /es/docs/Web/API/Document/getSelection /es/docs/Web/API/DocumentOrShadowRoot/pointerLockElement /es/docs/Web/API/Document/pointerLockElement /es/docs/Web/API/DocumentOrShadowRoot/styleSheets /es/docs/Web/API/Document/styleSheets /es/docs/Web/API/Element/accessKey /es/docs/Web/API/HTMLElement/accessKey diff --git a/files/es/_wikihistory.json b/files/es/_wikihistory.json index 9765fd105f..9cbfba64ba 100644 --- a/files/es/_wikihistory.json +++ b/files/es/_wikihistory.json @@ -23055,12 +23055,6 @@ "wbamberg" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2019-03-23T22:54:50.239Z", - "contributors": [ - "Diferno" - ] - }, "Web/API/HTMLElement/accessKey": { "modified": "2019-03-23T22:26:12.172Z", "contributors": [ @@ -23743,5 +23737,11 @@ "teoli", "HenryGR" ] + }, + "Web/API/Document/getSelection": { + "modified": "2019-03-23T22:54:50.239Z", + "contributors": [ + "Diferno" + ] } } \ No newline at end of file diff --git a/files/es/web/api/document/getselection/index.html b/files/es/web/api/document/getselection/index.html new file mode 100644 index 0000000000..465c75bc53 --- /dev/null +++ b/files/es/web/api/document/getselection/index.html @@ -0,0 +1,14 @@ +--- +title: Document.getSelection() +slug: Web/API/Document/getSelection +tags: + - Referencia + - Selección + - metodo +translation_of: Web/API/DocumentOrShadowRoot/getSelection +translation_of_original: Web/API/Document/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +

{{APIRef("DOM")}}

+ +

Este método funciona exactamente igual que {{domxref("Window.getSelection()")}}; devuelve un objeto {{domxref("Selection")}} que representa el texto que se ha seleccionado en el documento.

diff --git a/files/es/web/api/documentorshadowroot/getselection/index.html b/files/es/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index 21153bf09b..0000000000 --- a/files/es/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: Document.getSelection() -slug: Web/API/DocumentOrShadowRoot/getSelection -tags: - - Referencia - - Selección - - metodo -translation_of: Web/API/DocumentOrShadowRoot/getSelection -translation_of_original: Web/API/Document/getSelection -original_slug: Web/API/Document/getSelection ---- -

{{APIRef("DOM")}}

- -

Este método funciona exactamente igual que {{domxref("Window.getSelection()")}}; devuelve un objeto {{domxref("Selection")}} que representa el texto que se ha seleccionado en el documento.

diff --git a/files/fr/_redirects.txt b/files/fr/_redirects.txt index b2979d133f..9809f553ab 100644 --- a/files/fr/_redirects.txt +++ b/files/fr/_redirects.txt @@ -3749,8 +3749,8 @@ /fr/docs/Web/API/Document/defaultView/storage_event /fr/docs/Web/API/Window/storage_event /fr/docs/Web/API/Document/domConfig /fr/docs/Web/API/Document /fr/docs/Web/API/Document/elementFromPoint /fr/docs/Web/API/DocumentOrShadowRoot/elementFromPoint -/fr/docs/Web/API/Document/getSelection /fr/docs/Web/API/DocumentOrShadowRoot/getSelection /fr/docs/Web/API/DocumentOrShadowRoot/activeElement /fr/docs/Web/API/Document/activeElement +/fr/docs/Web/API/DocumentOrShadowRoot/getSelection /fr/docs/Web/API/Document/getSelection /fr/docs/Web/API/DocumentOrShadowRoot/styleSheets /fr/docs/Web/API/Document/styleSheets /fr/docs/Web/API/Document_Object_Model/Exemples /fr/docs/Web/API/Document_Object_Model/Examples /fr/docs/Web/API/Document_Object_Model/Introduction_au_DOM /fr/docs/Web/API/Document_Object_Model/Introduction @@ -3996,7 +3996,7 @@ /fr/docs/Web/API/document.createElementNS /fr/docs/Web/API/Document/createElementNS /fr/docs/Web/API/document.createRange /fr/docs/Web/API/Document/createRange /fr/docs/Web/API/document.defaultView /fr/docs/Web/API/Document/defaultView -/fr/docs/Web/API/document.getSelection /fr/docs/Web/API/DocumentOrShadowRoot/getSelection +/fr/docs/Web/API/document.getSelection /fr/docs/Web/API/Document/getSelection /fr/docs/Web/API/document.head /fr/docs/Web/API/Document/head /fr/docs/Web/API/document.location /fr/docs/Web/API/Document/location /fr/docs/Web/API/document.querySelector /fr/docs/Web/API/Document/querySelector diff --git a/files/fr/_wikihistory.json b/files/fr/_wikihistory.json index 082086a96f..1dc036a2a5 100644 --- a/files/fr/_wikihistory.json +++ b/files/fr/_wikihistory.json @@ -44980,16 +44980,6 @@ "BenoitL" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2019-09-25T07:21:02.389Z", - "contributors": [ - "julienc", - "sudwebdesign", - "loella16", - "fscholz", - "FredPl" - ] - }, "Web/API/HTMLElement/accessKey": { "modified": "2019-03-23T22:24:43.588Z", "contributors": [ @@ -46002,5 +45992,15 @@ "contributors": [ "SphinxKnight" ] + }, + "Web/API/Document/getSelection": { + "modified": "2019-09-25T07:21:02.389Z", + "contributors": [ + "julienc", + "sudwebdesign", + "loella16", + "fscholz", + "FredPl" + ] } } \ No newline at end of file diff --git a/files/fr/web/api/document/getselection/index.html b/files/fr/web/api/document/getselection/index.html new file mode 100644 index 0000000000..676ba4d351 --- /dev/null +++ b/files/fr/web/api/document/getselection/index.html @@ -0,0 +1,16 @@ +--- +title: document.getSelection +slug: Web/API/Document/getSelection +tags: + - API + - DOM + - Méthodes + - Reference + - Selection +translation_of: Web/API/DocumentOrShadowRoot/getSelection +translation_of_original: Web/API/Document/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +

{{APIRef("DOM")}}

+ +

Cette méthode fonctionne de manière identique à la méthode {{domxref ("Window.getSelection()")}} ; elle renvoie un objet {{domxref ("Selection")}} représentant le texte actuellement sélectionné dans le document.

diff --git a/files/fr/web/api/documentorshadowroot/getselection/index.html b/files/fr/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index dfe7b3a102..0000000000 --- a/files/fr/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: document.getSelection -slug: Web/API/DocumentOrShadowRoot/getSelection -tags: - - API - - DOM - - Méthodes - - Reference - - Selection -translation_of: Web/API/DocumentOrShadowRoot/getSelection -translation_of_original: Web/API/Document/getSelection -original_slug: Web/API/Document/getSelection ---- -

{{APIRef("DOM")}}

- -

Cette méthode fonctionne de manière identique à la méthode {{domxref ("Window.getSelection()")}} ; elle renvoie un objet {{domxref ("Selection")}} représentant le texte actuellement sélectionné dans le document.

diff --git a/files/ja/_redirects.txt b/files/ja/_redirects.txt index afbf74fa1e..6aeb1e8eaa 100644 --- a/files/ja/_redirects.txt +++ b/files/ja/_redirects.txt @@ -3747,12 +3747,12 @@ /ja/docs/Web/API/Document/defaultView/storage_event /ja/docs/Web/API/Window/storage_event /ja/docs/Web/API/Document/domConfig /ja/docs/Web/API/Document /ja/docs/Web/API/Document/elementFromPoint /ja/docs/Web/API/DocumentOrShadowRoot/elementFromPoint -/ja/docs/Web/API/Document/getSelection /ja/docs/conflicting/Web/API/DocumentOrShadowRoot/getSelection /ja/docs/Web/API/Document/inputEncoding /ja/docs/conflicting/Web/API/Document/characterSet /ja/docs/Web/API/Document/onselectionchange /ja/docs/Web/API/GlobalEventHandlers/onselectionchange /ja/docs/Web/API/DocumentOrShadowRoot/activeElement /ja/docs/Web/API/Document/activeElement /ja/docs/Web/API/DocumentOrShadowRoot/fullscreenElement /ja/docs/Web/API/Document/fullscreenElement /ja/docs/Web/API/DocumentOrShadowRoot/getAnimations /ja/docs/Web/API/Document/getAnimations +/ja/docs/Web/API/DocumentOrShadowRoot/getSelection /ja/docs/Web/API/Document/getSelection /ja/docs/Web/API/DocumentOrShadowRoot/msElementsFromRect /ja/docs/orphaned/Web/API/DocumentOrShadowRoot/msElementsFromRect /ja/docs/Web/API/DocumentOrShadowRoot/nodeFromPoint /ja/docs/conflicting/Web/API/DocumentOrShadowRoot /ja/docs/Web/API/DocumentOrShadowRoot/nodesFromPoint /ja/docs/conflicting/Web/API/DocumentOrShadowRoot_20ea0e1d91453a020aad3a16dbce16f1 diff --git a/files/ja/_wikihistory.json b/files/ja/_wikihistory.json index 3da558db6a..565d2b1182 100644 --- a/files/ja/_wikihistory.json +++ b/files/ja/_wikihistory.json @@ -12743,12 +12743,6 @@ "mfuji09" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2020-10-15T22:26:08.191Z", - "contributors": [ - "mfuji09" - ] - }, "Web/API/DocumentType": { "modified": "2020-10-15T22:09:56.256Z", "contributors": [ @@ -53496,5 +53490,11 @@ "contributors": [ "eltociear" ] + }, + "Web/API/Document/getSelection": { + "modified": "2020-10-15T22:26:08.191Z", + "contributors": [ + "mfuji09" + ] } } \ No newline at end of file diff --git a/files/ja/web/api/document/getselection/index.html b/files/ja/web/api/document/getselection/index.html new file mode 100644 index 0000000000..81fc970c85 --- /dev/null +++ b/files/ja/web/api/document/getselection/index.html @@ -0,0 +1,88 @@ +--- +title: DocumentOrShadowRoot.getSelection() +slug: Web/API/Document/getSelection +tags: + - API + - DocumentOrShadowRoot + - Doument + - Method + - Reference + - ShadowRoot + - getSelection + - getSelection() + - shadow dom +translation_of: Web/API/DocumentOrShadowRoot/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

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

+ +

構文

+ +
var selection = documentOrShadowRootInstance.getSelection()
+ +

引数

+ +

なし。

+ +

返値

+ +

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

+ +

+ +
function foo() {
+    var selObj = document.getSelection();
+    alert(selObj);
+    var selRange = selObj.getRangeAt(0);
+    // do stuff with the range
+}
+ +

メモ

+ +

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

+ +

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

+ +

上記の例では、 selObj.toString() が呼び出されてから {{DOMxRef("Window.alert()")}} に渡されます。しかし、 JavaScript の String のプロパティやメソッド、例えば lengthsubstr が {{DOMxRef("Selection")}} オブジェクトに対して呼び出されると、そのプロパティやメソッドを持っていないため、エラーが発生するか予期しない結果が返ることがあります。 Selection オブジェクトを文字列として扱うには、 toString() メソッドを直接呼び出してください。

+ +
var selectedText = selObj.toString();
+ + + + + +

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

+ +

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

+ +

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

+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName("Shadow DOM", "#extensions-to-the-documentorshadowroot-mixin", "DocumentOrShadowRoot")}}{{Spec2("Shadow DOM")}}初回定義
+ +

ブラウザーの互換性

+ +
+ + +

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

+
diff --git a/files/ja/web/api/documentorshadowroot/getselection/index.html b/files/ja/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index e201ed0675..0000000000 --- a/files/ja/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: DocumentOrShadowRoot.getSelection() -slug: Web/API/DocumentOrShadowRoot/getSelection -tags: - - API - - DocumentOrShadowRoot - - Doument - - Method - - Reference - - ShadowRoot - - getSelection - - getSelection() - - shadow dom -translation_of: Web/API/DocumentOrShadowRoot/getSelection ---- -
{{APIRef("DOM")}}{{SeeCompatTable}}
- -

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

- -

構文

- -
var selection = documentOrShadowRootInstance.getSelection()
- -

引数

- -

なし。

- -

返値

- -

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

- -

- -
function foo() {
-    var selObj = document.getSelection();
-    alert(selObj);
-    var selRange = selObj.getRangeAt(0);
-    // do stuff with the range
-}
- -

メモ

- -

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

- -

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

- -

上記の例では、 selObj.toString() が呼び出されてから {{DOMxRef("Window.alert()")}} に渡されます。しかし、 JavaScript の String のプロパティやメソッド、例えば lengthsubstr が {{DOMxRef("Selection")}} オブジェクトに対して呼び出されると、そのプロパティやメソッドを持っていないため、エラーが発生するか予期しない結果が返ることがあります。 Selection オブジェクトを文字列として扱うには、 toString() メソッドを直接呼び出してください。

- -
var selectedText = selObj.toString();
- - - - - -

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

- -

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

- -

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

- -

仕様書

- - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("Shadow DOM", "#extensions-to-the-documentorshadowroot-mixin", "DocumentOrShadowRoot")}}{{Spec2("Shadow DOM")}}初回定義
- -

ブラウザーの互換性

- -
- - -

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

-
diff --git a/files/ko/_redirects.txt b/files/ko/_redirects.txt index 256c8c220a..8d61ce0196 100644 --- a/files/ko/_redirects.txt +++ b/files/ko/_redirects.txt @@ -626,8 +626,8 @@ /ko/docs/Web/API/Document/defaultView/popstate_event /ko/docs/Web/API/Window/popstate_event /ko/docs/Web/API/Document/defaultView/resize_event /ko/docs/Web/API/Window/resize_event /ko/docs/Web/API/Document/drag_이벤트 /ko/docs/Web/API/Document/drag_event -/ko/docs/Web/API/Document/getSelection /ko/docs/Web/API/DocumentOrShadowRoot/getSelection /ko/docs/Web/API/DocumentOrShadowRoot/activeElement /ko/docs/Web/API/Document/activeElement +/ko/docs/Web/API/DocumentOrShadowRoot/getSelection /ko/docs/Web/API/Document/getSelection /ko/docs/Web/API/DocumentOrShadowRoot/styleSheets /ko/docs/Web/API/Document/styleSheets /ko/docs/Web/API/Document_Object_Model/Preface /ko/docs/Web/API/Document_Object_Model /ko/docs/Web/API/Document_Object_Model/소개 /ko/docs/Web/API/Document_Object_Model/Introduction diff --git a/files/ko/_wikihistory.json b/files/ko/_wikihistory.json index 4fda3210dc..c7cbc472de 100644 --- a/files/ko/_wikihistory.json +++ b/files/ko/_wikihistory.json @@ -18249,12 +18249,6 @@ "Sebuls" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2019-03-23T22:51:22.015Z", - "contributors": [ - "x86kernel" - ] - }, "Web/API/HTMLElement/accessKey": { "modified": "2020-10-15T22:14:28.158Z", "contributors": [ @@ -18704,5 +18698,11 @@ "alattalatta", "DeadIntegral" ] + }, + "Web/API/Document/getSelection": { + "modified": "2019-03-23T22:51:22.015Z", + "contributors": [ + "x86kernel" + ] } } \ No newline at end of file diff --git a/files/ko/web/api/document/getselection/index.html b/files/ko/web/api/document/getselection/index.html new file mode 100644 index 0000000000..919e52e9b3 --- /dev/null +++ b/files/ko/web/api/document/getselection/index.html @@ -0,0 +1,10 @@ +--- +title: Document.getSelection() +slug: Web/API/Document/getSelection +translation_of: Web/API/DocumentOrShadowRoot/getSelection +translation_of_original: Web/API/Document/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +

{{APIRef("DOM")}}

+ +

이 메소드는 {{domxref("Window.getSelection()")}} 와 동일합니다. 이 메소드는 {{domxref("Selection")}} 형의 객체를 반환하는데, 이 객체는 현재 페이지에서 선택된 영역의 정보를 반영합니다.

diff --git a/files/ko/web/api/documentorshadowroot/getselection/index.html b/files/ko/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index dee63369ab..0000000000 --- a/files/ko/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Document.getSelection() -slug: Web/API/DocumentOrShadowRoot/getSelection -translation_of: Web/API/DocumentOrShadowRoot/getSelection -translation_of_original: Web/API/Document/getSelection -original_slug: Web/API/Document/getSelection ---- -

{{APIRef("DOM")}}

- -

이 메소드는 {{domxref("Window.getSelection()")}} 와 동일합니다. 이 메소드는 {{domxref("Selection")}} 형의 객체를 반환하는데, 이 객체는 현재 페이지에서 선택된 영역의 정보를 반영합니다.

diff --git a/files/pt-br/_redirects.txt b/files/pt-br/_redirects.txt index 85ac13ea5b..85c7b192d6 100644 --- a/files/pt-br/_redirects.txt +++ b/files/pt-br/_redirects.txt @@ -555,8 +555,8 @@ /pt-BR/docs/Web/API/Document/defaultView/popstate_event /pt-BR/docs/Web/API/Window/popstate_event /pt-BR/docs/Web/API/Document/defaultView/resize_event /pt-BR/docs/Web/API/Window/resize_event /pt-BR/docs/Web/API/Document/elementFromPoint /pt-BR/docs/Web/API/DocumentOrShadowRoot/elementFromPoint -/pt-BR/docs/Web/API/Document/getSelection /pt-BR/docs/Web/API/DocumentOrShadowRoot/getSelection /pt-BR/docs/Web/API/DocumentOrShadowRoot/activeElement /pt-BR/docs/Web/API/Document/activeElement +/pt-BR/docs/Web/API/DocumentOrShadowRoot/getSelection /pt-BR/docs/Web/API/Document/getSelection /pt-BR/docs/Web/API/DocumentoXML /pt-BR/docs/Web/API/XMLDocument /pt-BR/docs/Web/API/Element.addEventListener /pt-BR/docs/Web/API/EventTarget/addEventListener /pt-BR/docs/Web/API/Element.getAttribute /pt-BR/docs/Web/API/Element/getAttribute diff --git a/files/pt-br/_wikihistory.json b/files/pt-br/_wikihistory.json index 8844ab7810..fc9965ff16 100644 --- a/files/pt-br/_wikihistory.json +++ b/files/pt-br/_wikihistory.json @@ -16964,12 +16964,6 @@ "cezaraugusto" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2019-03-23T22:54:15.369Z", - "contributors": [ - "expalmer" - ] - }, "Web/API/HTMLElement/accessKey": { "modified": "2019-03-23T22:27:15.059Z", "contributors": [ @@ -17367,5 +17361,11 @@ "fernandosavio", "DiegoYungh" ] + }, + "Web/API/Document/getSelection": { + "modified": "2019-03-23T22:54:15.369Z", + "contributors": [ + "expalmer" + ] } } \ No newline at end of file diff --git a/files/pt-br/web/api/document/getselection/index.html b/files/pt-br/web/api/document/getselection/index.html new file mode 100644 index 0000000000..24f7c5c180 --- /dev/null +++ b/files/pt-br/web/api/document/getselection/index.html @@ -0,0 +1,10 @@ +--- +title: Document.getSelection() +slug: Web/API/Document/getSelection +translation_of: Web/API/DocumentOrShadowRoot/getSelection +translation_of_original: Web/API/Document/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +

{{APIRef("DOM")}}

+ +

Esse método funciona de forma idêntica ao método {{domxref("Window.getSelection()")}};  Ele retorna um objeto {{domxref("Selection")}} representando o texto atualmente selecionado no documento.

diff --git a/files/pt-br/web/api/documentorshadowroot/getselection/index.html b/files/pt-br/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index 11fff02755..0000000000 --- a/files/pt-br/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Document.getSelection() -slug: Web/API/DocumentOrShadowRoot/getSelection -translation_of: Web/API/DocumentOrShadowRoot/getSelection -translation_of_original: Web/API/Document/getSelection -original_slug: Web/API/Document/getSelection ---- -

{{APIRef("DOM")}}

- -

Esse método funciona de forma idêntica ao método {{domxref("Window.getSelection()")}};  Ele retorna um objeto {{domxref("Selection")}} representando o texto atualmente selecionado no documento.

diff --git a/files/ru/_redirects.txt b/files/ru/_redirects.txt index 217bd711d9..e397148064 100644 --- a/files/ru/_redirects.txt +++ b/files/ru/_redirects.txt @@ -402,8 +402,8 @@ /ru/docs/Web/API/Document/defaultView/resize_event /ru/docs/Web/API/Window/resize_event /ru/docs/Web/API/Document/defaultView/storage_event /ru/docs/Web/API/Window/storage_event /ru/docs/Web/API/Document/domConfig /ru/docs/Web/API/Document -/ru/docs/Web/API/Document/getSelection /ru/docs/Web/API/DocumentOrShadowRoot/getSelection /ru/docs/Web/API/DocumentOrShadowRoot/activeElement /ru/docs/Web/API/Document/activeElement +/ru/docs/Web/API/DocumentOrShadowRoot/getSelection /ru/docs/Web/API/Document/getSelection /ru/docs/Web/API/Element.getBoundingClientRect /ru/docs/Web/API/Element/getBoundingClientRect /ru/docs/Web/API/Element.insertAdjacentHTML /ru/docs/Web/API/Element/insertAdjacentHTML /ru/docs/Web/API/Element/accessKey /ru/docs/Web/API/HTMLElement/accessKey diff --git a/files/ru/_wikihistory.json b/files/ru/_wikihistory.json index 170225c76e..196f623a1a 100644 --- a/files/ru/_wikihistory.json +++ b/files/ru/_wikihistory.json @@ -25203,12 +25203,6 @@ "Aleksej" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2019-03-23T22:34:05.751Z", - "contributors": [ - "YakovL" - ] - }, "Web/API/HTMLElement/accessKey": { "modified": "2019-03-23T22:51:14.902Z", "contributors": [ @@ -25988,5 +25982,11 @@ "contributors": [ "d0rj" ] + }, + "Web/API/Document/getSelection": { + "modified": "2019-03-23T22:34:05.751Z", + "contributors": [ + "YakovL" + ] } } \ No newline at end of file diff --git a/files/ru/web/api/document/getselection/index.html b/files/ru/web/api/document/getselection/index.html new file mode 100644 index 0000000000..e04e36513d --- /dev/null +++ b/files/ru/web/api/document/getselection/index.html @@ -0,0 +1,10 @@ +--- +title: Document.getSelection() +slug: Web/API/Document/getSelection +translation_of: Web/API/DocumentOrShadowRoot/getSelection +translation_of_original: Web/API/Document/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +

{{APIRef("DOM")}}

+ +

Этот метод работает в точности так же, как {{domxref("Window.getSelection()")}}; он возвращает объект {{domxref("Selection")}}, в котором содержатся данные о тексте, выделенном в документе на данный момент.

diff --git a/files/ru/web/api/documentorshadowroot/getselection/index.html b/files/ru/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index ce4007b2f3..0000000000 --- a/files/ru/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Document.getSelection() -slug: Web/API/DocumentOrShadowRoot/getSelection -translation_of: Web/API/DocumentOrShadowRoot/getSelection -translation_of_original: Web/API/Document/getSelection -original_slug: Web/API/Document/getSelection ---- -

{{APIRef("DOM")}}

- -

Этот метод работает в точности так же, как {{domxref("Window.getSelection()")}}; он возвращает объект {{domxref("Selection")}}, в котором содержатся данные о тексте, выделенном в документе на данный момент.

diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index 9ee008a3bd..3908924a1b 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -1485,7 +1485,6 @@ /zh-CN/docs/Web/API/Document/domConfig /zh-CN/docs/Web/API/Document /zh-CN/docs/Web/API/Document/elementFromPoint /zh-CN/docs/conflicting/Web/API/DocumentOrShadowRoot/elementFromPoint /zh-CN/docs/Web/API/Document/elementsFromPoint /zh-CN/docs/conflicting/Web/API/DocumentOrShadowRoot/elementsFromPoint -/zh-CN/docs/Web/API/Document/getSelection /zh-CN/docs/conflicting/Web/API/DocumentOrShadowRoot/getSelection /zh-CN/docs/Web/API/Document/inputEncoding /zh-CN/docs/conflicting/Web/API/Document/characterSet /zh-CN/docs/Web/API/Document/mozFullScreen /zh-CN/docs/Web/API/Document/fullscreen /zh-CN/docs/Web/API/Document/mozFullScreenElement /zh-CN/docs/Web/API/Document/fullscreenElement @@ -1494,6 +1493,7 @@ /zh-CN/docs/Web/API/Document/rouchmove_event /zh-CN/docs/Web/API/Document/touchmove_event /zh-CN/docs/Web/API/DocumentOrShadowRoot/activeElement /zh-CN/docs/Web/API/Document/activeElement /zh-CN/docs/Web/API/DocumentOrShadowRoot/fullscreenElement /zh-CN/docs/Web/API/Document/fullscreenElement +/zh-CN/docs/Web/API/DocumentOrShadowRoot/getSelection /zh-CN/docs/Web/API/Document/getSelection /zh-CN/docs/Web/API/DocumentOrShadowRoot/pointerLockElement /zh-CN/docs/Web/API/Document/pointerLockElement /zh-CN/docs/Web/API/DocumentOrShadowRoot/styleSheets /zh-CN/docs/Web/API/Document/styleSheets /zh-CN/docs/Web/API/Document_Object_Model/Preface /zh-CN/docs/conflicting/Web/API/Document_Object_Model diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index 6bb3beb84a..524f81d1c5 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -10384,12 +10384,6 @@ "1Cr18Ni9" ] }, - "Web/API/DocumentOrShadowRoot/getSelection": { - "modified": "2020-10-15T22:12:59.602Z", - "contributors": [ - "WuCongMan" - ] - }, "Web/API/DocumentTouch": { "modified": "2019-03-23T22:57:10.414Z", "contributors": [ @@ -50798,5 +50792,11 @@ "contributors": [ "lastVigo" ] + }, + "Web/API/Document/getSelection": { + "modified": "2020-10-15T22:12:59.602Z", + "contributors": [ + "WuCongMan" + ] } } \ No newline at end of file diff --git a/files/zh-cn/web/api/document/getselection/index.html b/files/zh-cn/web/api/document/getselection/index.html new file mode 100644 index 0000000000..f3eca58f61 --- /dev/null +++ b/files/zh-cn/web/api/document/getselection/index.html @@ -0,0 +1,76 @@ +--- +title: DocumentOrShadowRoot.getSelection() +slug: Web/API/Document/getSelection +translation_of: Web/API/DocumentOrShadowRoot/getSelection +original_slug: Web/API/DocumentOrShadowRoot/getSelection +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

The getSelection() property of the {{DOMxRef("DocumentOrShadowRoot")}} interface returns a {{DOMxRef("Selection")}} object representing the range of text selected by the user, or the current position of the caret.

+ +

Syntax

+ +
var selection = documentOrShadowRootInstance.getSelection()
+ +

Parameters

+ +

None.

+ +

Returns

+ +

A {{DOMxRef("Selection")}} object.

+ +

Example

+ +
function foo() {
+    var selObj = document.getSelection();
+    alert(selObj);
+    var selRange = selObj.getRangeAt(0);
+    // do stuff with the range
+}
+ +

Notes

+ +

String representation of the Selection object

+ +

In JavaScript, when an object is passed to a function expecting a string (like {{DOMxRef("Window.alert()")}}), the object's {{JSxRef("Object.toString", "toString()")}} method is called and the returned value is passed to the function. This can make the object appear to be a string when used with other functions when it is really an object with properties and methods.

+ +

In the above example, selObj.toString() is automatically called when it is passed to {{DOMxRef("Window.alert()")}}. However, attempting to use a JavaScript String property or method such as length or substr directly on a {{DOMxRef("Selection")}} object results in an error if it does not have that property or method and may return unexpected results if it does. To use a Selection object as a string, call its toString() method directly:

+ +
var selectedText = selObj.toString();
+ + + + + +

HTML inputs provide simpler helper APIs for working with selection (see {{DOMxRef("HTMLInputElement.setSelectionRange()")}}).

+ +

Notice the difference between selection and focus. {{DOMxRef("Document.activeElement")}} returns the focused element.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Shadow DOM", "#extensions-to-the-documentorshadowroot-mixin", "DocumentOrShadowRoot")}}{{Spec2("Shadow DOM")}}Initial definition.
+ +

Browser Compatibility

+ +
+ + +

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

+
diff --git a/files/zh-cn/web/api/documentorshadowroot/getselection/index.html b/files/zh-cn/web/api/documentorshadowroot/getselection/index.html deleted file mode 100644 index 7110d24d21..0000000000 --- a/files/zh-cn/web/api/documentorshadowroot/getselection/index.html +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: DocumentOrShadowRoot.getSelection() -slug: Web/API/DocumentOrShadowRoot/getSelection -translation_of: Web/API/DocumentOrShadowRoot/getSelection ---- -
{{APIRef("DOM")}}{{SeeCompatTable}}
- -

The getSelection() property of the {{DOMxRef("DocumentOrShadowRoot")}} interface returns a {{DOMxRef("Selection")}} object representing the range of text selected by the user, or the current position of the caret.

- -

Syntax

- -
var selection = documentOrShadowRootInstance.getSelection()
- -

Parameters

- -

None.

- -

Returns

- -

A {{DOMxRef("Selection")}} object.

- -

Example

- -
function foo() {
-    var selObj = document.getSelection();
-    alert(selObj);
-    var selRange = selObj.getRangeAt(0);
-    // do stuff with the range
-}
- -

Notes

- -

String representation of the Selection object

- -

In JavaScript, when an object is passed to a function expecting a string (like {{DOMxRef("Window.alert()")}}), the object's {{JSxRef("Object.toString", "toString()")}} method is called and the returned value is passed to the function. This can make the object appear to be a string when used with other functions when it is really an object with properties and methods.

- -

In the above example, selObj.toString() is automatically called when it is passed to {{DOMxRef("Window.alert()")}}. However, attempting to use a JavaScript String property or method such as length or substr directly on a {{DOMxRef("Selection")}} object results in an error if it does not have that property or method and may return unexpected results if it does. To use a Selection object as a string, call its toString() method directly:

- -
var selectedText = selObj.toString();
- - - - - -

HTML inputs provide simpler helper APIs for working with selection (see {{DOMxRef("HTMLInputElement.setSelectionRange()")}}).

- -

Notice the difference between selection and focus. {{DOMxRef("Document.activeElement")}} returns the focused element.

- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("Shadow DOM", "#extensions-to-the-documentorshadowroot-mixin", "DocumentOrShadowRoot")}}{{Spec2("Shadow DOM")}}Initial definition.
- -

Browser Compatibility

- -
- - -

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

-
-- cgit v1.2.3-54-g00ecf