We started testing our application in IE11 and have noticed that window.getSelection() is not getting a selection in IE11 . I don't see any where that this property is not supported in IE11, and as per my understanding window.getSelection
should work in all IE versions from 9.
Has anyone else come across this issue? Am I missing something here ?
I have created the below example which would work as expected in older version of IE and also in Chrome but not in IE11.
$('#selectButton').on('click', function() {
$('#name').select();
var sel = window.getSelection();
alert("Slected value in text area : " + sel);
}
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form name='selectAll' id='selectAll'>
<textarea id='name' name='name'>Sample Value</textarea>
<br>
<input type='button' value='Click Me' id='selectButton' />
</form>
UPDATE - On further investigation I have figured out the window.getSelection() does exist in IE 11 but it will not work when the text selected is within an input field like text area. I also know that there used to be a similar bug in FF . At this point I am not sure whether this is a bug in IE or an expected behavior.