Unable to get property 'createRange' of undefined or null reference
The documentation for document.selection
says right at the top:
selection is no longer supported. Starting with Internet Explorer 11, use getSelection. For info, see Compatibility changes.
Change document.selection.createRange().text
to document.getSelection()
.
The problem was exactly what I predicted. You are calling createRange()
on a null or undefined reference. Specifically, document.selection
is undefined. The error message said exactly what was wrong.