Results 1 to 5 of 5

Thread: JavaScript popup windows onLoad event

  1. #1

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141

    JavaScript popup windows onLoad event

    If I popup a window by doing
    var newwin = window.open(Url, Name, Properties);

    Is there a way to know on the opener page when the popup finishes loading? I have a page that is basicly a copy of another domains page with all the links going to the other domain. (don't ask why, it just makes it look like part of the site I am building). The problem is that none of the links work unless the browser has a cookie from that domain. I thought about opening a page from their site in a hidden iframe so that you wouldn't know you were loading it, but IE 6 defaults to not allowing cookies from a different domain. I finally came up with the idea of loading a popup of their site, and closing it after 1 or 2 seconds. It works most of the time, but sometimes it closes before the cookie loads. I just need to know when the popup is done loading, so that I can close it.
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In the popup's onload:
    window.opener.notifyLoaded();

    where notifyLoaded is a function you define in the main window.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141
    I don't have access to the popup html. What I need, and probably can't get is to know when the popup loads from the opener.
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I don't think that's possible without a timer.

    But you could try this:
    Code:
    var win = null;
    
    function setOnLoad()
    {
      if(!win)
        return;
      if(win && !win.document.body) {
        setTimeout(100, setOnLoad);
        return;
      }
    
      win.document.body.onload = pageLoaded;
    }
    
    function createWin()
    {
      win = window.open(blabla);
      setOnLoad();
    }
    Not sure if it works though.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141
    Hey that is a great idea!!! I will try that.
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width