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

前端 未结 18 1125
囚心锁ツ
囚心锁ツ 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 21:14

    I just visited this site and it really bugged me,

    apparently there are a couple ways to disable the mouse click:

    1)

    <script language="javascript">
    document.onmousedown=disableclick;
    status="Right Click Disabled";
    function disableclick(event)
    {
      if(event.button==2)
       {
         alert(status);
         return false;    
       }
    }
    </script>
    

    and

    <body oncontextmenu="return false">
    

    ...

    in this case what you will have to do in the dev tools is :

    document.removeEventListener("onmousedown",disableclick);
    document.oncontextmenu = function(){}
    

    2)

    using flash as a content wrapper - no solution here except taking a screenshot

    3)

    some sites want to prevent downloading images via right click -> save image as

    so what they do is put this:

    <div style="background-image: url(YourImage.jpg);">
       <img src="transparent.gif"/>
    </div>
    

    which is a transparent image spreding on the full width and height of the screen all you need to do is go to the elements inspector and find the div and delete it.

    In my case #1 did the trick

    0 讨论(0)
  • 2021-01-29 21:14

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

    0 讨论(0)
  • 2021-01-29 21:16

    Another possible way, when the blocking function is made with jquery, use:

    $(document).unbind();
    

    It will clear all the onmousedown and contextmenu events attributed dynamically, that can't be erased with document.contextmenu=null; etc.

    0 讨论(0)
  • 2021-01-29 21:16

    The way I solved this was delete the event listeners on the page. After I did that, I was able to copy the text and paste it in to my processor of choice.

    0 讨论(0)
  • 2021-01-29 21:18

    Disabling the "SETTINGS > PRIVACY > don´t allow JavaScript" in Chrome will enable the right click function and allow the Firebug Console to work; but will also disable all the other JavaScript codes.

    The right way to do this is to disable only the specific JavaScript; looking for any of the following lines of code:

    • Function disableclick
    • Function click … return false;
    • body oncontextmenu="return false;"
    0 讨论(0)
  • 2021-01-29 21:22

    On the very left of the Chrome Developer Tools toolbar there is a button that lets you select an item to inspect regardless of context menu handlers. It looks like a square with arrow pointing to the center.

    0 讨论(0)
提交回复
热议问题