rose337
asked on
Frame Checking
Good day.
I have a site with two frames. I have javascript in both frames and occassionally, one frame will run javascript that is in the other frame.
Everything works well except at startup when one frame tries to run javascript that is in the other frame, and that frame has not loaded it yet, then I get a debug error.
So the right frame wants to run the function Test() which is in the left frame. So what I did was write this javascript in the right frame.
function myonload()
{
myTimer = setTimeout("myonload()",10 0);
if (parent.frames.Left.Test() )
{
clearTimeout(myTimer);
}
}
which obviously just keeps trying to run Test() until it can and then all is well. This seems to occassionally (particularly in older browsers) to pull an error saying that it could not run
if (parent.frames.Left.Test() )
which is obviously because it has not loaded yet. So this seems to be pointless.
Is there a way to test if the frame has loaded yet? I though about playing around with the onload events of each frame but it ends up a vicious circle because the left frame also wants to run javascript in the right frame. I am sure that you will see what I mean when you play with the idea.
I have a site with two frames. I have javascript in both frames and occassionally, one frame will run javascript that is in the other frame.
Everything works well except at startup when one frame tries to run javascript that is in the other frame, and that frame has not loaded it yet, then I get a debug error.
So the right frame wants to run the function Test() which is in the left frame. So what I did was write this javascript in the right frame.
function myonload()
{
myTimer = setTimeout("myonload()",10
if (parent.frames.Left.Test()
{
clearTimeout(myTimer);
}
}
which obviously just keeps trying to run Test() until it can and then all is well. This seems to occassionally (particularly in older browsers) to pull an error saying that it could not run
if (parent.frames.Left.Test()
which is obviously because it has not loaded yet. So this seems to be pointless.
Is there a way to test if the frame has loaded yet? I though about playing around with the onload events of each frame but it ends up a vicious circle because the left frame also wants to run javascript in the right frame. I am sure that you will see what I mean when you play with the idea.
ASKER
Unfortunately the javascript that runs in either frame does things to the images and content in that frame, which is why I need to keep the javascript where it is. Thus I do need the frame to load properly. Thanks anyway.
ASKER
Unfortunately the javascript that runs in either frame does things to the images and content in that frame, which is why I need to keep the javascript where it is. Thus I do need the frame to load properly. Thanks anyway.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm assuming (and could be wrong!) that there's nothing in the script that gets info from either frame in particular. As long as whatever you need is in the script, and not in either frame, it will work fine regardless of whether the other frame is loaded or not.