Reputation: 41954
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.
Upvotes: 630
Views: 404573
Reputation: 51
you can use the below script which lets to debug the popover when clicked.
document.addEventListener('click', ()=>{
{debugger}
})
Upvotes: 5
Reputation: 4189
You can enable the Emulate a focused page setting in the Elements panel > Styles tab.
This setting is available the Style tab since the recent Chrome 123 updates.
The popover show/hide in Bootstrap is determine by the page's focus state (document.hasFocus()
), not the element's hover state.
When you inspect the element with DevTools open, the focus is shifted to DevTools, which considered as a separate page. Therefore, we need to "fake" (emulate) the focus back to the page. There's a detailed explanation in this video.
Upvotes: 1
Reputation: 1116
Based on great idea of @frzsombor, I have written a chrome extension that help you freeze the DOM instantly for debugging and validating purpose. Under the hood, it call debugger
command from chrome extension instead of waiting for the timeout in console to be triggered right at the moment / the state you want
https://chrome.google.com/webstore/detail/freeze-dom/onekmnelbichmlnmkecckkjjljifhefg
How to use it:
Upvotes: 3
Reputation: 51
Fn+F12-->3 dots in inspector right side-->more tools -->Rendering--> select Emulate a focused page
Upvotes: 5
Reputation: 1784
I found another way to do this.
If your element is shown by a click on a button then hides when focus is removed, just right-click and copy the button's selector, then go to the Elements panel in dev tools and hit Esc to open the console at the same time.
Then right-click again on the button and "inspect" to reveal that part of the HTML in the document.
Go back to your console and manually trigger the click event using: document.querySelector('#yourButtonSelector').click()
Then it goes into the desired state while your focus is on DevTools, and you can click around the Elements panel without causing it to disappear. Hope this helps!
Upvotes: 0
Reputation: 1699
You can use Bookmarklets to run a script to enter debugging mode (and thus freeze the viewport including all active states. It's the easiest method to inspect elements hidden behind a state if you ask me.
Freeze
for examplejavascript: setTimeout(()=>{debugger}, 2000)
⌘ + Shift + C
is my go to or F12
)Freeze
bookmarkObviously you can change the interval until the debugger activates. Hope this helps!
Upvotes: 4
Reputation: 2560
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)
<body>
and click "Edit as HTML"<body>
then press Ctrl+Enter: <div id="debugFreeze" data-rand="0"></div>
setTimeout(function(){$("#debugFreeze").attr("data-rand",Math.random())},5000);
Of course you can modify the javascript and the timing, if you get the idea.
Upvotes: 146
Reputation: 335
I recently ran into this issue and pressing F8
solution didn't work for me. Here's how I froze the hover element.
Elements
tab.Event Listeners
mouseout
eventremove
button shown there.mouseover
event but cannot trigger mouseout
when your curser leave the element, since we deleted that.Upvotes: 8
Reputation: 7537
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 ):
screenshot of instructions:
Upvotes: 2
Reputation: 159
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
Upvotes: 0
Reputation: 4170
I tried the other solutions here, they work but I'm lazy so this is my solution
by right clicking it no longer registers mouse event since a context menu pops up, so you can move the mouse away safely
Upvotes: 6
Reputation: 41954
Got it working. Here was my procedure:
Sources
tab in chrome inspectorElements
tab in inspectorUpvotes: 983
Reputation: 72271
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.
Elements
tab in the Chrome Inspector, and you can look for your element there. 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.
Upvotes: 588
Reputation: 367
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.
Upvotes: 24
Reputation: 8413
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. Upvotes: 65