How to disable copy paste in website?

I want to turn off copy feature from my site

Asked on September 17, 2021 in Website.
Add Comment
  • 1 Answer(s)

    Disable cut, copy, and paste options.

    <script language="text/javascript">
        // disable portal cut copy and paste options.
        $('body').bind('cut copy paste', function (e) {
                e.preventDefault();
        });
    
    </script>
    

    But I prefer to enable this option on localhost.

    <script language="text/javascript">
        // disable portal cut copy and paste options.
        $('body').bind('cut copy paste', function (e) {
    
           // enable only localhost
           if (location.hostname === "localhost" || location.hostname === "127.0.0.1") 
            {
                return;
            }
            e.preventDefault();
    
        });
    
    </script>
    
    Answered on September 17, 2021.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.