I am new to javascript, trying to perform:
document.selection.createRange();
but document.selection
always returns unde
Try document.getSelection()
or window.getSelection()
.
Here's a quick example that I tested in chrome
http://jsfiddle.net/hgDwx/
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.
Use window.getSelection()
instead.
https://developer.mozilla.org/en/DOM/window.getSelection