sheodox
sheodox

Reputation: 825

Debugging JavaScript in popup windows on Chrome

What is a good way to debug a popup window in Chrome? I need to debug some code that is run when the window is opened and I was wondering if there was a better way to debug it than pressing f12 as soon as the window opens. I'm looking for something similar to using Visual Studio where you can open a window, set a breakpoint on some JS, then open the window back up and VS will break on that breakpoint without you having to do anything.

If it can be done some way on Firefox I'd switch to that, as long as I don't have to use IE.

Upvotes: 5

Views: 5417

Answers (2)

sheodox
sheodox

Reputation: 825

Nowadays there's an option in the Chrome devtools settings. "Auto-open DevTools for popups". screenshot of the setting checkbox

Check that checkbox, then if you have devtools open on the parent window and that opens a popup or new tab devtools will automatically open in that window/tab.

Upvotes: 4

Positive Navid
Positive Navid

Reputation: 2781

Short Answer:

"Ctrl + click"

Long Answer:

I had the same problem. It seems that it's a bug in Google Chrome and there's nothing we can do about it until it is fixed in future versions. I found a way around it, though, which is not an actual solution but solved my problem.

1) Close the popup window.

2) Open it again using "Ctrl + click" instead of just clicking on the link to the popup window.

3) The window will be opened in a new normal tab.

4) Now you can press F12 and go to debug mode.

Hope this solves someone else's problem too.

Upvotes: 1

Related Questions