Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to tell if a popup has fully loaded

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is it possible to tell from a parent window if a popup window has fully loaded?

I'm running some javascript on a popup window from a parent window and it can only be done once the popup has fully loaded. Is this possible? I can set a timer, but that does not guarantee that the popup fill fully load before the timer expires, unless I set the timer to a large value, but that is awkward for the user.

How is a situation like this typically handled?

Thanks!
Homer
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
put an onload handler on the popup window which can call a function on the parent telling it that it is loaded

for example you can just do

<body onload="window.opener.YourFunction()">

If that does not work because you can not touch the code of the popup since your partner is anal about people changing their code, you can put a try catch statement in the opener and call it every X milliseconds and when it sees the element, it knows the page is loaded.

Eric
 
Homer Hill
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric.

I would need to use the second method you described as I can't touch the code in the popup window.

Just to clarify, are you saying that I should do something like this:

popup = window.open(...);
loaded = false;
while (loaded == false) {
try {
if (popup) { //will this line return true ONLY when the popup has loaded?
loaded = true;
}
<execute javascript on popup>
} catch (e) {
}
}

thnx
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little confused. Does JS also support struct?

Thanks,
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what I came up with:



A while loop would freeze the browser.

Hope it helps...
Eric
[ June 07, 2005: Message edited by: Eric Pascarello ]
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sophie Cameron:
A little confused. Does JS also support struct?

Thanks,




Yes there is a try catch
 
Evildoers! Eat my justice! And this tiny ad's justice too!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic