If you go to a website and read something interesting there. You want to copy that piece of the quote but when you right-click it, nothing happens. Okay, then this tutorial is definitely for you. Many websites disable right-clicking on their pages to stop theft or copying. There is a void document method behind this madness but it doesn’t work for users. void document oncontextmenu=null is a piece of JavaScript you can use to work around it.
There are a few ways to enable the inability to right-click on web pages. While I do not condone copyright theft or copying of entire pages, I do support the ability to take quotes, useful pieces of code or other snippets from pages for your own use. And if you need to copy only parts of the text, then these options may make more sense.
Contents
How to Enable Right-Click on Websites?
Depending on the website in question, the administrator will use JavaScript or HTML code to block the right-click context menu. There are bunches of ways you can work around this limitation and using void document oncontextmenu=null is just one of them. I’ll describe a few of the ways here.
If you land on a webpage and want to copy something from it, try pasting void document oncontextmenu=null into the URL bar of the page. You should now be able to right-click as normal. And do what you need to do. You will need to do this every time you want to copy something. But yes it works like a charm on many pages.
It is not universal though as there is a range of ways website owners use to block right-click. If that doesn’t work. Then try one of these methods for the void document.
Save the Page:
This is the easiest way I have found around the right-click block is to save the entire page as HTML. Then open it in the browser again and can right-click, copy, paste and do whatever I like. This is actually very useful if there are multiple quotes or pieces of code I want to use for the void documents.
This works with most browsers although if you use Edge, you may have to save the page as HTML. Then open it in Firefox or Chrome to get it working properly. I had trouble getting it to work and you may do too.
Disable JavaScript Altogether:
This is something if a nuclear option as it can completely break web pages. If the website uses JavaScript to block the right-click dialog, disabling it will stop it from interfering with what you’re doing. How you do that depends on the browser you’re using.
If you use in Firefox:
- Open a new tab and type ‘about config’.
- Search for JavaScript.
- Double click ‘javascript.enabled to make it false instead of true.
If you use in Chrome:
- Select the three-dot menu icon in the top right and select Settings.
- Then Select Advanced and Content Settings within Privacy and Security.
- Select JavaScript and toggle it to off.
If you disable JavaScript it can stop some sites from working properly and some from working at all. Use this setting carefully and only if you need to. for the void document.
Use a Browser Plugin:
More effective than disabling JavaScript altogether is the use of plugins to re-enable the right-click dialog. Firefox and Chrome have a bunch of them and also some of them work perfectly. Search your default browser plugin section for ‘right click’ or words to that effect. Then see what comes up with void document.
I use Firefox Quantum and over thousands of results came up for ‘right click’. Some of them are irrelevant but the top few plugins. Where exactly what I was looking for. You should find the same whatever browser you use.
Going to the Source:
If you only occasionally need to copy something from web pages. Then you may just find it easier to view the source code. While adding void document oncontextmenu=null to the URL bar takes less time. Having the code around isn’t always going to be convenient. just Remember Ctrl + U will be.
Open the page you want to. Then right-click on and hit Ctrl + U. It will bring up a new tab showing the source code of the page. You can scour the code for the text you need to Ctrl + F to find it. You can also then be able to copy the text as required and without any problems. Both Ctrl + U and Ctrl + F will work on all recent browsers. The ability to right-click and copy text from web pages should be used sparingly and only when necessary. A lot of time and effort goes into creating content for you to enjoy so please copy responsibly!
I hope now you get to use void document oncontextmenu=null. And I hope you liked my article