Testing whether a frame has been loaded from the frameset page
November 02, 2007
Javascript | Web Building

Have you ever tried to use a javascript to modify the properties of a frame? Particularly a javascript ON the frameset page? If you have tried, you probably know that timing plays an important role. If the frame in question has not yet been rendered, you will get javascript errors such as "element 'X' has no properties" .

I've found that even if the function call is placed at the end of the frameset page, by the time it is reached, the frameset may not be fully loaded. I'm not sure, but I think that sometimes the frames don't fully show up as "loaded" until their source pages are also loaded. And even worse, Internet Explorer may not even SEE the javascript if it is placed at the end of a frameset page.

The solution I've found is to use setTimeout as suggested by Johan Godfried on irt.org:


function changeframeSrc(){
if(frames[0]){//alert('yes');
frames[0].location='page03.htm';}
else{setTimeout("changeframeSrc()",100);}
}

changeframeSrc();



Ads by Google

Posted by ellen at November 02, 2007 01:32 PM


Ads by Google

 RSS   |   Contact Me

Ads by Google

Ads by Google