Labels

php (34) javascript (30) phpjavascript (29) jquery (23) html (19) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Wednesday, January 24, 2018

JavaScript to Disable Mouse Right Click ,Cut, Copy and Paste Options

If we want to prevent the user from copying content from a web page,
we need to disable right click and also we need to disable the copy, cut,
paste options.

<!DOCTYPE html>

<html lang="en">

<head>

    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

    <!--Javascript code for disable right click-->

    <script>
        $(document).ready(function(){
            $(document).on("contextmenu",function(e){
                return false;
            });
        });
    </script>

    <!--Javascript code for disable cut,copy,paste-->

    <script>
        $(document).ready(function(){
            $(document).on("cut copy paste",function(e){
                return false;
            });
        });
    </script>

</head>

<body>

1. contextmenu (also called contextual, shortcut, and pop up or pop-up menu) is a menu in a graphical user interface (GUI) that appears upon user interaction, such as a right-click mouse operation.

2. The on( ) method attaches one or more event handlers for the selected elements and child elements like cut, copy, paste.

</body>

</html>
                              

No comments:

Post a Comment

More Posts

FOLLOW