I am new to javascript, trying to perform:
document.selection.createRange();
but document.selection always returns undefined.
I am using latest version of chrome.
what am I doing wrong?
thanks!
I am new to javascript, trying to perform:
document.selection.createRange();
but document.selection always returns undefined.
I am using latest version of chrome.
what am I doing wrong?
thanks!
Browser support for the selection object based on IE11 and Chrome 87.04280.141
| Member | IE | Chrome |
|---|---|---|
document.selection |
yes | no |
window.selection |
no | no |
document.getSelection() |
no | yes |
window.getSelection() |
no | yes |
This is the easy part.
The problems come when you are trying to use any methods, f.e. getRange() which exists for document.selection (IE compatible), but doesn't exist for document.getSelection(), so for Chrome you need a workaround.