Search code examples
javascriptios6safari

window.getSelection() not working in ios6 device?


In my application i used java script to get selected text.this will be work perfectly in simulator but ios6 device return null string.

var select = window.getSelection();
var selObj = select.toString()

Solution

  • Look at How to captured Selected Text Range in iOS after text selection expansion. It's very thorough and the answer has a working jsfiddle (which should be able to answer your question).

    This answer seems to answer and go beyond your question (as well as address another possible issue you might find).