Monday, July 30, 2018

Script to Disable Mouse Right Click

Script to Disable Mouse Right Click

  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $(".disableEvent").on("contextmenu",function(){
  4. alert('right click disabled');
  5. return false;
  6. });
  7. });
  8. </script>

Script to Disable Cut Copy & Paste

Using this script, you can prevent user to cut (CTRL+X), copy (CTRL+C) and paste (CTRL+V)content from your web pages.
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $('.disableEvent').bind('cut copy paste', function (e) {
  4. e.preventDefault();
  5. });
  6. });
  7. </script>
  8. As far as I can see, the secret sauce is, that Ctrl+S does NOT fire the keypress event, only the keydown event.
    $(document).bind('keydown', 'ctrl+s', function(e) {
        e.preventDefault();
        alert('Ctrl+S');
        return false;
    });
    Only with jQuery:
    $(document).bind('keydown', function(e) {
      if(e.ctrlKey && (e.which == 83)) {
        e.preventDefault();
        alert('Ctrl+S');
        return false;
      }
    });

    Disable saving web page with CTRL-S using JQuery

    Use below JQuery code to disable saving web page using "CTRL-S" keyword directly. This will work well on all browser (IE, Firefox, Google chrome). // To prevent saving web site directly using "ctrl-s" $(document).bind('keydown keypress', 'ctrl+s', function () {         $('#save').click();         return false;     });
     

No comments:

Post a Comment