Search code examples
javascriptinternet-explorerinternet-explorer-10getselection

getSelection() broken in IE10


I use the window.getSelection() method on my project to make a quotable text

It's working just fine in all modern browsers, exept IE10. In IE10 console returns correct text, but the selection is broken.

The only code I used:

text = window.getSelection().toString();
console.log(text);

This code calls on mouseup event.

Does anyone know the solution?


Solution

  • try this should work for ie < 9.0

    var texttest = document.selection.createRange();
    alert (texttest.text);
    

    this is for all browsers except ie < 9.0

    var texttest = document.getSelection();
    alert(texttest);