Detect popup window in IE6

Discussion in 'Javascript' started by lrlebron@gmail.com, Jun 13, 2007.

  1. Guest

    I am using the following to detect if a popup window is already open.
    I only want to open a new window if it does not exist or has been
    closed.
    <HTML>
    <HEAD>
    <script language="JavaScript" type="text/javascript">
    <!--
    var myPage;
    function openMyPage() {
    if (!myPage || myPage.closed){
    myPage=window.open("default.aspx", "_blank");
    }
    else {
    alert("NFSL1 is already opened");
    }
    }
    //-->
    </script>

    </HEAD>
    <BODY>
    <FORM>
    <INPUT TYPE="button" onClick="openMyPage();" VALUE="open MyPage">
    </FORM>
    </BODY>
    </HTML>


    The code works correctly in Firefox, but IE6 opens a new window every
    time.

    Any ideas?

    thanks,

    Luis
     
    , Jun 13, 2007
    #1
    1. Advertising

  2. wrote:
    > myPage=window.open("default.aspx", "_blank");
    >


    The second argument should be the name (myPage) not a target (_blank).


    JW
     
    Janwillem Borleffs, Jun 13, 2007
    #2
    1. Advertising

  3. Randy Webb Guest

    Janwillem Borleffs said the following on 6/13/2007 4:48 PM:
    > wrote:
    >> myPage=window.open("default.aspx", "_blank");
    >>

    >
    > The second argument should be the name (myPage) not a target (_blank).


    And it should be opening a window with the name of "_blank" - which it
    is - but IE <gasp> gets it right and opens a new blank window each time.

    Solution: give it a different name other than _blank.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jun 13, 2007
    #3
  4. Roger Guest

    Randy Webb wrote:
    > Janwillem Borleffs said the following on 6/13/2007 4:48 PM:
    >> wrote:
    >>> myPage=window.open("default.aspx", "_blank");
    >>>

    >>
    >> The second argument should be the name (myPage) not a target (_blank).

    >
    > And it should be opening a window with the name of "_blank" - which it
    > is - but IE <gasp> gets it right and opens a new blank window each time.
    >
    > Solution: give it a different name other than _blank.
    >


    Also, if you give the window a name the first time it is opened, you do
    not have to bother testing to see if the window is still open. Just
    request another new window using the same name and any existing window
    with the requested name will get reused.

    Roger
     
    Roger, Jun 13, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Drew Berkemeyer
    Replies:
    7
    Views:
    5,899
    Steven Cheng[MSFT]
    Oct 24, 2004
  2. Terren
    Replies:
    6
    Views:
    156
    Dave Anderson
    Sep 28, 2005
  3. Jens Peter Hansen
    Replies:
    7
    Views:
    566
    Randy Webb
    Jun 19, 2004
  4. Raffi
    Replies:
    4
    Views:
    243
    Dr John Stockton
    Aug 12, 2004
  5. Replies:
    0
    Views:
    94
Loading...

Share This Page