Does chrome supports document.selection?

Viewed 19777

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!

4 Answers

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.

Related