Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-enable right click so that I can inspect HTML elements in Chrome?

I am looking at a web page which has overwritten the right-click button so to display its own popup HTML element.

This prevents me from using Chrome Developer Tools to inspect elements.

Does anybody know a JavaScript snippet I could inject from the Chrome Console to re-enable the right-click?

I am okay to break the existing 'right-click' functionality, so to be able to inspect the HTML elements easily.

Thanks.

like image 504
Zo72 Avatar asked Jan 24 '14 14:01

Zo72


People also ask

How do you inspect element in Chrome if right click disabled?

Use Ctrl + Shift + C (or Cmd + Shift + C on Mac) to open the DevTools in Inspect Element mode, or toggle Inspect Element mode if the DevTools are already open.

How do you enable right click using inspect element?

If the page you are on has a text or textarea input, click into this input (as if you want to enter text) then right-click and select 'Inspect element'. Show activity on this post. There you will find Enable right click. Click on it.


1 Answers

If they have just changed the oncontextmenu handler (which is the most straightforward way to do it), then you can remove their override thus:

window.oncontextmenu = null; 

Otherwise, if it is attached to individual elements, you can get all the page's elements, and then remove the handler on each one:

var elements = document.getElementsByTagName("*"); for(var id = 0; id < elements.length; ++id) { elements[id].oncontextmenu = null; } 

Or, it seems you can turn off such scripts; via an extension in Chrome or an option in Firefox - in the advanced box for javascript options, switch off 'Disable or replace context menus'.

like image 126
Phil H Avatar answered Sep 22 '22 02:09

Phil H