Check if window is popup or not

Posted on 2009-04-20
Last Modified: 2013-11-19
Hi, I need to detect if the current window is a popup or not.

 I think opener won't work for me since I have already browsed some links in the window and I always get 'main window' after checking opener.

Thanks in advance !
Question by:blueshaolin
    LVL 39

    Accepted Solution

    if opener doesnt work, set a variable on the window:

    var mywindow = (....);
    mywindow.isPopup = true;

    then check for the presence of the isPopup variable on the window object (undefined or true) and you should be fine.

    Author Comment

    Thanks..... the problem was that the 'current window' is in a frame, so the opener isn't really the Main page.

    Solution: check window.parent.opener


    Author Closing Comment

    I didn't give enough information since I didn't know the page/window was a frame. The solution to the given problem is right!
    LVL 39

    Expert Comment

    glad you found it. Thanks for giving me the credits still for answering to the original q. :)

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now