问题
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?
回答1:
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
回答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
来源:https://stackoverflow.com/questions/14598070/cross-browser-disable-the-user-select-ctrl-a