Tuesday 23 October 2018

How to disable right click, cut(ctrl+X), copy(ctrl+C), paste(ctrl+V), inspect(ctrl+shift+I)

Using the below mentioned scripts we can disable right click, cut(ctrl+X), copy(ctrl+C), paste(ctrl+V), inspect(ctrl+shift+I). So that we can secure our website getting copied by others.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        window.oncontextmenu = function () {
            return false;
        }
        $(document).keydown(function (event) {
            if (event.keyCode == 123) {
                return false;
            }
            else if ((event.ctrlKey && event.shiftKey && event.keyCode == 73) || (event.ctrlKey && event.shiftKey && event.keyCode == 74)) {
                return false;
            }
        });
    </script>
      <script type="text/javascript">
          function disableselect(e) {
              return false
          }

          function reEnable() {
              return true
          }

          //if IE4+
          document.onselectstart = new Function("return false")
          document.oncontextmenu = new Function("return false")
          //if NS6
          if (window.sidebar) {
              document.onmousedown = disableselect
              document.onclick = reEnable
          }
</script>

No comments:

Post a Comment