admin管理员组文章数量:1326675
Is there a way to determine if the current window is a popup? This is what I have right now but for some reason it is not working. I am trying to make sure that certain pages are only shown in popup window.
if(!opener)
window.location = 'error.php';
The value of opener is [object DOMWindow] even though the window is not popup.
Is there a way to determine if the current window is a popup? This is what I have right now but for some reason it is not working. I am trying to make sure that certain pages are only shown in popup window.
if(!opener)
window.location = 'error.php';
The value of opener is [object DOMWindow] even though the window is not popup.
Share Improve this question edited Aug 6, 2011 at 6:18 Eyad Fallatah asked Aug 5, 2011 at 22:24 Eyad FallatahEyad Fallatah 1,9484 gold badges24 silver badges36 bronze badges 2-
Do you get an error when it doesn't work? what is the value of
opener
when you think it should work but it doesn't? – Dan Davies Brackett Commented Aug 6, 2011 at 0:02 - The value of opener is [object DOMWindow] even though the window is not popup. – Eyad Fallatah Commented Aug 6, 2011 at 6:18
1 Answer
Reset to default 8Assuming you're opening popup windows yourself- set a flag:
var myWindow = window.open(...);
myWindow.isPopup = true;
then, in your popup window, check for the flag:
if (!window.isPopup) {
window.location = 'error.php';
}
本文标签: javascriptif window is popupStack Overflow
版权声明:本文标题:javascript - if window is popup - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742201584a2432060.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论