Javascript : How To Disable ctrl+c and ctrl+u On Your Website


There are cases where you don’t want users to copy your content or view source in your website. So to do this just add the below piece of javascript code in your website and its done.


jQuery(document).ready(function($){
    $(document).keydown(function(event) { 
        var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
        
        if (event.ctrlKey && (pressedKey == "c" || pressedKey == "u")) {
            alert('Sorry, This Functionality Has Been Disabled!'); 
            //disable key press porcessing
            return false; 
        }
    });
});

Note: You can’t protect your source.

Tagged with:
Posted in Javascript

Leave a comment