Use window.getSelection()
, which is the most cross-browser compatible (it’s supported in the current versions of all major browsers) and is the standard. Chrome certainly supports it as fully as other browsers.
document.selection
should only be used for IE < 9.
More Related Contents:
- Official locator strategies for the webdriver
- Use a content script to access the page context variables and functions
- Weird behavior with objects & console.log [duplicate]
- Can a website detect when you are using Selenium with chromedriver?
- Suppress Chrome ‘Failed to load resource’ messages in console
- Uncaught SyntaxError: Unexpected token :
- Jquery load() only working in firefox?
- Chrome Uncaught Syntax Error: Unexpected Token ILLEGAL [duplicate]
- Get element CSS property (width/height) value as it was set (in percent/em/px/etc)
- Violation Long running JavaScript task took xx ms
- How to disable JavaScript in Chrome Developer Tools?
- Unexpected token ILLEGAL in webkit
- Does execCommand SaveAs work in Firefox?
- Chrome extension: How to remove orphaned script after chrom extension update
- Loading external javascript in google chrome extension
- How to keep Google Chrome Extension popup open?
- What happens to code after a javascript redirect (setting window.location.href)?
- ‘load’ event not firing when iframe is loaded in Chrome
- Getting unique ClientID from chrome extension?
- Is it possible to control the camera light on a phone via a website?
- Content-Security-Policy error in google chrome extension making
- Forcing garbage collection in Google Chrome
- In a Chrome Extension content script, must I wait for document.ready before processing the document?
- MediaRecorder.stop() doesn’t clear the recording icon in the tab
- Detect left mouse button press
- Accessing line number in V8 JavaScript (Chrome & Node.js)
- Choppy/Laggy scroll event on Chrome and IE
- How do I listen for triple clicks in JavaScript?
- How to develop Chrome extension for Gmail?
- How to open mailto links in new tab for users that have gmail as the default mail handler?