In this post, we will see how we can disable right click option using simple JQuery code. I hope you will like it.
Most of the developers are always looking for the safety of their images and code blocks which they have shared in the web. But normally it is hard to secure this unless you go for any third party tool. Some of us may think if we just disable the right click option in our page, makes the content secured. But it is not. If some one really thinks that they need to get the content from your page, they can achieve it. Even though that is the reality, I am sharing this post to show how to disable the right click option in page.
Using the code
We are going to use JQuery for this requirement. So you need to load the JQuery reference first.
Now we need to add the needful scripts.
Here what we did is, whenever user tries to perform right click in the document, we are restricting that. We are applying this restriction to the entire document. And we use contextmenu event to do this requirement.
That is all. Everything is done and set. Now you need to see the output and demo right?
You can see a demo at Disable Right Click Option Demo
You can see right click option is not allowed in the demo page. You can always gives an alert also, if a user performs right click.
I hope you liked my article. Now please share me your feedback. Thanks in advance.