This question is not the duplicate of if window is popup , But a similar one.
I am developing a extension which injects scripts to all web pages. I need to detect whether the window is popup or not.
Note: I am not the one who is opening the popup window, So the above solution won't work.
Pop-up Source IdentificationIf you see an address bar at the top of the window and the Firefox logo in the window's upper-left corner, Firefox is generating the pop-up. If you use another browser, such as Chrome, look for an address bar and the browser's logo in that pop-up.
In short, you can check if any element has ui-popup-active class. If there is, then you have popup open. Observe that, if popup is closed, it will have ui-popup-hidden class.
A pop-up is a graphical user interface ( GUI ) display area, usually a small window, that suddenly appears ("pops up") in the foreground of the visual interface.
I've found that some browsers will set window.opener to window in certain cases. This is the most reliable popup check that I am using right now.
if (window.opener && window.opener !== window) { // you are in a popup }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With