My last post on file structure lab program is getting listed first when you google for ” fs lab”, “file structure lab” and many more related keywords. This is driving a lot of visitors to the site.
File structure lab being introduced for the first time in 6th Semester, Department of Information Science, VTU. Hence there is no lab programs available with anyone, neither the seniors have it nor it is available on the whole internet. SandeepHegde.me is the only site where you can find the programs and I want to keep it the same. I don’t mind people using the program for their personal use or internal circulation. What I don’t like is copying the program onto other websites. In such cases you can provide link to SandeepHegde.me from that site.
So I’m making a small attempt to reduce copying articles from my site. I’m disabling the right click feature from SandeepHegde.me and it today’s post is all about how to disable right click (Context Menu) in your HTML page. Here it goes….
HTML has an event called “oncontextmenu”. This event handles the right click event.
So, if you want to disable right click for any field in your page, all you have to do is add “oncontextmenu” inside the particular tag. The example below will make things clear.
Ex. Suppose you want to prevent users from copy pasting something into one of your text boxes. Then you need to write the input tag as follows:
<input type=”text” oncontextmenu=”return false;”>
That’s it!! The context menu does not appear because we are handling the right click event by returning false.
Alternatively, you can disable right click for the whole page as follows:
Just copy paste the following code after the end of your <form> tag.
<script>
document.oncontextmenu = function(){return false}
</script>
I do not really know how far the web browsers can support it, but there is nothing wrong in giving a try.
Please comment your queries.
[Request : If you are using someone else’s content, Please leave an credit to the Original Author ]
chloe says
this really works! thanks!
sandeephegde says
Dear chloe,
Thanks for visiting the site. If the article has helped it served my purpose of writing it 🙂
Wee says
GREAT! WORKS WELL!