Site icon SmartTutorials.net

jQuery Script to Disable Right Click And Control Save on your Site

This following jQuery script help you to prevent your html page from saving as well prevent the access of html source code.

 

Demo

jQuery script to disable right click and control save on your site

jQuery script to disable right click option of browser on your html page or site.

$(document).bind('contextmenu',function(e){
       e.preventDefault();
});

or

$(document).bind('contextmenu',function(e){
       return false;
});

jQuery script to disable control + save( Ctrl+ s) option of windows OS on your html page or site.

$(window).unbind('keypress').keypress(function(event) {
   if (!(event.which == 115 && event.ctrlKey))return true;
              event.preventDefault();
	      return false;
});

 

If your non-programmer please follow this steps to add this script to your site.

Steps:

1. Find the following </body> tag in your html source code.
2. Now copy the below script and paste before closing </body> tag.

<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
<script>
(function ($) {
          $(document).bind('contextmenu',function(e){
	       e.preventDefault();
	  });
	  $(window).unbind('keypress').keypress(function(event) {
		if (!(event.which == 115 && event.ctrlKey))return true;
			    event.preventDefault();
			    return false;
		});

}(jQuery));
</script>

 .

Exit mobile version