ChatGPT解决这个技术问题 Extra ChatGPT

Freeze screen in chrome debugger / DevTools panel for popover inspection?

I'm using the chrome inspector to try and analyze the z-index of a twitter bootstrap popover, and finding it extremely frustrating...

Is there a way to freeze the popover (while shown) so that I can assess and modify the associated CSS?

Placing a fixed 'hover' on the associated link does not cause the popover to appear.

Try setting a breakpoint in your JavaScript immediately after the popup is shown (debugger;)
I use window.setTimeout to trigger debugger in 5 seconds, then hover over element and wait.
Hello, DevTools technical writer here. Can you all send me MVCEs demonstrating the problem? As of 2019 we have a few tools that should do the trick (event listener breakpoints, pseudo-class toggles) but I can't provide a detailed answer until I can reproduce your situation.
You can found other solution here for Chrome & Firefox
@KayceBasques Here's an example: telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist Click on the dropdown list to open it, then try inspecting the list content popover in the Elements view.

A
Abram

Got it working. Here was my procedure:

Browse to the desired page Open the dev console - F12 on Windows/Linux or option + ⌘ + J on macOS Select the Sources tab in chrome inspector In the web browser window, hover over the desired element to initiate the popover Hit F8 on Windows/Linux (or fn + F8 on macOS) while the popover is showing. If you have clicked anywhere on the actual page F8 will do nothing. Your last click needs to be somewhere in the inspector, like the sources tab Go to the Elements tab in inspector Find your popover (it will be nested in the trigger element's HTML) Have fun modifying the CSS


This workflow gave me a short, useful introduction to the breakpoint debugger and helped isolate a menu that was difficult to style, as it disappeared on Console click.
If the DOM element uses the focusout event to hide you have no chance to hit F8!
@Dean to trigger F8 you need to use fn!
For more info, what F8 shortcut does is actually pause the debugger(script execution). And ctrl + \ also works. (cmd + \ in MacOS).
It's great fun refreshing the page and trying to fn+f8 at just the right moment. They should release it as a game on Steam.
C
Community

To be able to inspect any element do the following. This should work even if it's hard to duplicate the hover state:

Run the following javascript in the console. This will break into the debugger in 5 seconds. setTimeout(function(){debugger;}, 5000)

Go show your element (by hovering or however) and wait until Chrome breaks into the Debugger.

Now click on the Elements tab in the Chrome Inspector, and you can look for your element there.

You may also be able to click on the Find Element icon (looks like a magnifying glass) and Chrome will let you go and inspect and find your element on the page by right clicking on it, then choosing Inspect Element

Note that this approach is a slight variation to this other great answer on this page.


i respect that you paid proper respect to frzsombor's answer. nice.
This is what I needed, as the functionality was due to a DOM element getting added on js Focus, and removed on blur, which always happens when you switch to the dev tools.
Abram's F8 solution did not work for me. This one did. Thanks!
Thx. I made a bookmark with title: ❚❚, address: javascript:debugger;. F8 works, but for those who prefer to use mouse this might be more convenient.
As others have commented the F8 answer was not working for me, and was driving me completely nuts! This works like a charm. Thank you!
f
frzsombor

UPDATE: As Brad Parks wrote in his comment there is a much better and easier solution with only one line of JS code:

run setTimeout(function(){debugger;},5000);, then go show your element and wait until it breaks into the Debugger

Original answer:

I just had the same problem, and I think I found an "universal" solution. (assuming the site uses jQuery) Hope it helps someone!

Go to elements tab in inspector Right click and click "Edit as HTML" Add the following element after then press Ctrl+Enter:

Right click this new element, and select "Break on..." -> "Attributes modifications" Now go to Console view and run the following command: setTimeout(function(){$("#debugFreeze").attr("data-rand",Math.random())},5000); Now go back to the browser window and you have 5 seconds to find your element and click/hover/focus/etc it, before the breakpoint will be hit and the browser will "freeze". Now you can inspect your clicked/hovered/focused/etc element in peace.

Of course you can modify the javascript and the timing, if you get the idea.


Hey! Great idea... you don't even need to add the extra div though... Just run this javascript instead setTimeout(function(){debugger;}, 5000);, then go show your element and wait until it breaks into the Debugger. Then click on the "Elements" tab in the Chrome Inspector, and you can look for your element there. You may also abe able to click on the "Find Element" icon (looks like a magnifying glass) and Chrome will let you go and inspect and find your element on the page by right clicking on it, then choosing "Inspect Element".
I don't have f8 on my keyboard, this answer saved me, thanks
Thanks this helped me, I added the following and did the trick: onclick="setTimeout(function(){debugger;},5000);"
A
Adrian Enriquez

Right click anywhere inside Elements Tab Choose Breakon... > subtree modifications Trigger the popup you want to see and it will freeze if it see changes in the DOM If you still don't see the popup, click Step over the next function(F10) button beside Resume(F8) in the upper top center of the chrome until you freeze the popup you want to see.


L
Leah Huyghe

I found that this works really well in Chrome.

Right click on the element that you'd like to inspect, then click Force Element State > Hover. Screenshot attached.

https://i.stack.imgur.com/1xqc4.png


It will work only if the popover is triggered by css.
R
ROOT

I tried the other solutions here, they work but I'm lazy so this is my solution

hover over the element to trigger expanded state ctrl+shift+c hover over element again right click navigate to the debugger

by right clicking it no longer registers mouse event since a context menu pops up, so you can move the mouse away safely


M
M Ali Imtiaz

Previously My Chrome Freeze feature was not working by pressing f8 shortcut Key , i use this walk around and goto Source Tab and just clicked on Pause / play on Script Execution button in right panel of chrome Dev tools in Source Tab, My short cut key that got fixed and started to work from then, Really thank full , Fixed my problem


V
Vincent Gerris

None of the solutions worked for me, only the one as described on : https://developer.chrome.com/docs/devtools/javascript/disable/

for Linux ( for Mac use command instead of comtrol ):

Open developer tools ( ctrl + shift + I )

Run command window ( ctrl + shift + P )

Start typing javascript and select disable javascript

screenshot of instructions:

https://i.stack.imgur.com/8MFjx.png


A
A. Morel

If you right click on element, you freeze the browser.

https://i.stack.imgur.com/4qDWq.gif