How to prevent webpage download

It is difficult to guard your website content being stolen. But we can implement some basic protections. Here are some techniques which tested in latest version of Chrome, Firefox, Edge and Brave browsers in Windows 10 operating system.

To prevent/disable copy, cut in a web page using jQuery.

<body ondragstart="return false" onselectstart="return false">
<script> 
$(document).ready(function() {
$('body').bind('cut copy', function(e) {
e.preventDefault();
});
$("body").on("contextmenu", function(e) {
return false;
});
});
</script>

To prevent/disable F12 key in the browser using jQuery.

<script> 
$(document).keydown(function (event) {
if (event.keyCode == 123) {
return false;
} else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) { // Prevent Ctrl+Shift+I
return false;
}
});

</script>

To prevent/disable Ctrl+s and Ctrl+u key in the browser using jQuery.

<script> 
$(document).bind('keydown', function(e) {
if(e.ctrlKey && (e.which == 83 || e.which == 85)) {
e.preventDefault();
return false;
}
});

</script>

Leave a Comment

Your email address will not be published. Required fields are marked *