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

前端 未结 18 1155
囚心锁ツ
囚心锁ツ 2021-01-29 20:55

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

18条回答
  •  北荒
    北荒 (楼主)
    2021-01-29 20:57

    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'.

提交回复
热议问题