I use the following javascript code that blocks ordinary users (and not professionals, of course) from using the print screen and Ctrl + A and Ctrl + C in the browser. it works as expected in Firefox and Chrome, but sometimes it works on IE, and in other cases it fails. Please review the code if you can help a bit, it is possible that it will go wrong in IE. and why does it fail?
function disableselect(e) {
return false;
}
function reEnable() {
return true;
}
document.onselectstart = new Function("return false");
if (window.sidebar) {
document.onmousedown = disableselect;
document.onclick = reEnable;
}
function copyToClipboard() {
var aux = document.createElement("input");
aux.setAttribute("value", "You can no longer give print-screen. This is part of the new system security measure");
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
alert("You can no longer give print-screen. This is part of the new system security measure.");
}
$(window).keyup(function(e){
if(e.keyCode == 44){
copyToClipboard();
}
});
$(window).focus(function() {
$("body").show();
}).blur(function() {
$("body").hide();
});
source
share