Monday, 16 July 2018

Disable Mouse Right Click using jquery

////////// using jquery liv-

http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js


      <script type="text/javascript">
                $(document).ready(function () {
                    //Disable full page
                    $("body").on("contextmenu", function (e) {
                        return false;
                    });

                    //Disable particular part of the page
                    $("#id").on("contextmenu", function (e) {
                        return false;
                    });
                });
            </script>

///////////////////////// or

<script type="text/javascript">
                    $(document).ready(function () {
                        $(document)[0].oncontextmenu = function () { return false; }
                        $(document).mousedown(function (e) {
                            if (e.button == 2) {
                                alert('Sorry, This functionality is not enable!');
                                return false;
                            } else {
                                return true;
                            }
                        });
                    });

                </script>

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...