How to detect that my window is open in popup? I'm need detect when my site opened in popup window (window.open, not in target=_blank window)
Asked
Active
Viewed 950 times
-1
-
2Possible duplicate of [Check whether a window is Popup or not?](https://stackoverflow.com/questions/10240398/check-whether-a-window-is-popup-or-not) – str Aug 10 '17 at 11:17
-
1This is super simple to find before asking a question: https://www.google.com/search?q=stackoverflow+How+to+detect+that+my+window+is+open+in+popup – str Aug 10 '17 at 11:18
-
Using listeners can help you, maybe you can [try this](https://stackoverflow.com/a/3030893/711143). – Onit4ku Aug 10 '17 at 11:21
1 Answers
0
if(window.opener)
{
alert('the page is inside a pop-up window or target=_blank');
}
else
{
alert('Not a pop-up or target=_blank');
}
It's not possible to know if a window is a Pop-up
or _blank
if you don't have the control over the pop-up attributes.
My hint to maybe make this possible would be to read the parent window html and look for the window.open('yourpage') script being (true or false).
Best regards
-
-
Do you have control over the window.open params? If you do, you can set the title or other params like width or height in order to check if it is your Popup. – Methark Aug 10 '17 at 13:25
-
My page open from other site. if she open from target=_blank this is good. If she open from window.open this is bad – Vinni Aug 10 '17 at 13:38
-