How to disable ctrl+click to select text in IE 10?
Asked Answered
R

2

6

In IE 10, when you click on any text while holding the CTRL key the browser selects the text (which means the text gains focus and I want to avoid this because I have some multi-select scenario where CTRL+click means add/remove-select).

How can I disable this "feature"?

BTW, I still want to be able to select the text using the usual mouse actions.

Rus answered 17/9, 2012 at 11:46 Comment(2)
You need to talk to some UI boys. Overriding standard behaviours is something users find confusing and irritating, leaving them with the impression that you couldn't be bothered with them.Thao
I think you comment should be forwarded to the IE10 team... ;)Rus
C
4

This feature can be disabled by disabling selection completely.

This can be done by using -ms-user-select which has been introduced in IE10. (see also: http://ie.microsoft.com/testdrive/HTML5/msUserSelect/Default.html)

Example: To disable selection add the following css class to the element containing the text or one of its parents:

.notselectable
{
    -ms-user-select: none;
}
Curley answered 20/9, 2012 at 8:42 Comment(0)
P
0

To prevent IE 8 CTRL and SHIFT click text selection on individual element, use this:

var obj = document.createElement("DIV");
obj.onselectstart = function(){
  return false;
}

To prevent text selection on document, use this:

window.onload = function(){
  document.onselectstart = function(){
    return false;
  }
}
Pitchblack answered 18/11, 2014 at 22:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.