IE 8 getSelection().anchorOffset alternative
问题 I have got a Javascript code, which works well for modern browsers: var offset = getSelection().anchorOffset; var node = getSelection().anchorNode; How can I get the same result on IE 8, which does not have window.getSelection() method? 回答1: There is a solution. It is possible to extend browser's object model using Rangy library: window.getSelection = rangy.getSelection As it may take some time for Rangy to init and as we will not need this for modern browsers, some more workaround: /* IE 8