0

By default the user can drag and select the screen item / press CTRL + A ,all the item will be turn blue and blur (selected). However, is there any way to block this event? Thanks

Are there any simple way just like adding some restriction in browser or adding some attribute in body tag can solve the problem?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
user782104
  • 13,233
  • 55
  • 172
  • 312
  • why u need this ? if user turn off the javascript then ? – Ravi Gadag Jan 30 '13 at 06:38
  • possible duplicate of [css rule to disable text selection highlighting](http://stackoverflow.com/questions/826782/css-rule-to-disable-text-selection-highlighting) – Ravi Gadag Jan 30 '13 at 06:42

2 Answers2

4
user-select:none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;

Add Following user-select property to that element which you do not want to turn blue. Adding it to body will turn selectable or editable elements to not be selectable or editable. So, it is recommended to use it on specific elements e.g.

div, image, iframe {
    user-select:none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

Or You can See More on:

Documentation

Muhammad Talha Akbar
  • 9,952
  • 6
  • 38
  • 62
2

You can do it by using jquery

$(function(){   
$(document).keydown(function(objEvent) {        
    if (objEvent.ctrlKey) {          
        if (objEvent.keyCode == 65) {                         
            objEvent.disableTextSelect();
            return false;
        }            
    }        
});
});    

Hope it works,this code disable ctrl+a on browser