Cross browser disables user selection (Ctrl + A)

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

Is there any simple way how adding a restriction in the browser or adding some attribute to the body tag can solve the problem?

0
source share
2 answers
user-select:none; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; 

Add a user-select property to this element that you do not want in blue. Adding it to the body will make selectable or editable elements not selectable or editable . Therefore, it is recommended to use it for certain elements, for example.

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

Or you can Read more:

Documentation

+4
source

You can do it using jquery

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

Hope this works, this code will disable ctrl + a in the browser

+2
source

Source: https://habr.com/ru/post/1482481/


All Articles