I want to disable any image selecting in my website. I already use this code:
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
but still have a problem with CTRL+A. Is there any jQuery or Javascript code to disable CTRL+A and select all function?
EDIT : this is my website > http://narenjco.ir/ press ctrl+a in first page , i want to make sparks unselectable
Edit: I now see that you've applied it to the images within the .unselectable
class. In Chrome these images are unselectable, so the issue appears to be browser-specific. To overcome this problem in whichever browser you're using you'll need to use JavaScript.
It's all to do with the usage of your user-select:none
. Currently, I can't see on your site where this has been applied, however applying it to the body
tag does prevent Ctrl+A from selecting any content (in Chrome at least).
body {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
Try this
$(function(){
$(document).keydown(function(objEvent) {
if (objEvent.ctrlKey) {
if (objEvent.keyCode == 65) {
return false;
}
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With