Some times as a web developer and programmer, you may
require to disable right click on your webpages for certain reasons like
probably you are a blogger and you labor so hard to research and write your
various blog posts and you do not want it to get copied then the solution is to
disable the right click button that gives your website users access to other
options of actions they wish to perform on your webpages or maybe you are a
programmer and you do not want people to be able to see your html, css and
JavaScript source codes and make use of them, then these
tutorials is for you. To disable the right click action on your web pages, you
should;
Before I continue, it is important that I mention to you
that I personally does not support the implementation of these trick on every
website you build, design or develop as you could bring about a certain kind of
restriction to your users which may not be favourable to the growth of your
website or maybe your blog but you could implement it on certain kind of
websites like if you are building a result checking website, though not on all
the pages but the result checking page, you could implement this trick to stop
some very sharp students from being able to edit their results on your webpage
just like the popular waec website www.waecdirect.org
. below are the steps to implement this trick;
1)
In the head section of the webpage, reference the j-query javascript library
either from a CDN (content delivery Network) server like the google CDn severs
or even jquery’s cdn servers or you reference j-query from your very own server
which I prefer as I love to control everything about my webpages most especially
the physical outlook of the webpages that make up a website. Reference them
using the following code
<script src=”myscripts/jquery.js”
type=”text/javscript”></script>
2)
Then as usual reference your custom script in
the same webpabge as follows
<script src=”myscripts/script1.js”
type=”text/javascript”></script>
3)
Here comes the real part, inside your custom
script ” script1.js” as mentioned above, place the following code
inside of it;
$document.ready(function(){
$(document).bind(“contextmenu”’function(e){
Return false;
});
});
4)
Once you have done the above, save it and see
the exciting and experienced results.
0 comments:
Post a Comment