开发者

Diff between document.getSelection() and window.getSelection()

Also can you please answer this question? how do I get co-ordinates of selected text in an html using javascript document.getSelecttion()

thanks开发者_开发技巧


You get error message Deprecated method document.getSelection() called. Please use window.getSelection() instead." in Firefox which means document.getSelection() is a deprecated method.


They seem to be the same:

https://w3c.github.io/selection-api/#dom-document-getselection

getSelection() method
The method must return the selection associated with this if this has an associated browsing context, and it must return null otherwise.

https://w3c.github.io/selection-api/#dom-window-getselection

getSelection() method
The method must invoke and return the result of getSelection() on this's Window.document attribute.

Editors of MDN say they're equivalent:

https://developer.mozilla.org/en-US/docs/Web/API/Document/getSelection

You can call Window.getSelection(), which works identically to Document.getSelection().

https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection

You can call Document.getSelection(), which works identically to Window.getSelection().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜