spunog
asked on
Applet not loaded in time for call
I have a frameset with two frames. One frame is a hidden, and contains an applet. I have an call to this applet from the onLoad event within the body tag of the other frame. However a javascript error occurs every time as the applet is not yet loaded. How can I ensure that the applet is loaded properly ? The error message is :
Object doesnt support this property or method.
My code is as follows:
<HTML>
<TITLE>The Title</TITLE>
<script>
function Launch()
{
parent.main.location = parent.hidden.document.LMS Applet.app letMethod( );
}
</script>
<BODY onload="Launch()">
</BODY>
</HTML>
Object doesnt support this property or method.
My code is as follows:
<HTML>
<TITLE>The Title</TITLE>
<script>
function Launch()
{
parent.main.location = parent.hidden.document.LMS
}
</script>
<BODY onload="Launch()">
</BODY>
</HTML>
I don't have code here with me to show you, but one thought on a solution would be to display the text 'loading applet' in the visible frame. After the amount of time you think it should take to load the applet, reload the visible frame with the content that is dependent on the applet. Sorry I don't have any code to show you since I'm at work.
ASKER
I know what you mean all right but there would always be a chance that it might not have loaded within the time given. Is there a flag or something within all applets to say whether it has been loaded ??
try this:
function Launch()
{
var UNDEFINED; // do not assign
if ( parent.hidden.document.LMS Applet == UNDEFINED )
setTimeout('Launch()',1000 ); // wait another second
else // applet is loaded
parent.main.location = parent.hidden.document.LMS Applet.app letMethod( );
}
function Launch()
{
var UNDEFINED; // do not assign
if ( parent.hidden.document.LMS
setTimeout('Launch()',1000
else // applet is loaded
parent.main.location = parent.hidden.document.LMS
}
ASKER
That still gives the same error message. The javascript error icon appears before it starts loading the other pages. I tried setting the delay at a longer time but it doesn't seem to be even waiting ! I also put the method call in the onload tag of the hidden frame ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If that does not work maybe you need to show us the code for the hidden page.
Cd&
Cd&
yeah, the problem might be with this line:
if ( parent.hidden.document.LMS Applet == UNDEFINED )
can you do this in the hidden frame?
<BODY onLoad='self.loaded=true;' >
if so, then change the line in the function above to this:
if ( parent.hidden.loaded )
if ( parent.hidden.document.LMS
can you do this in the hidden frame?
<BODY onLoad='self.loaded=true;'
if so, then change the line in the function above to this:
if ( parent.hidden.loaded )
sorry Cd&, I didn't notice your comments.
Great minds... :^)
Cd&
Cd&
ASKER
With that, the error changes to Object expected on line one of the main page.
The hidden frame is :
<html>
<APPLET CODE="LMSApplet.class" archive="lmsApplet.jar"WID TH=1 HEIGHT=1 alt="Launch Applet" NAME="LMSApplet" >
<param name=cabbase value="lmsApplet.cab">
</APPLET>
<script language="JavaScript">
var loadflag=false;
</script>
<body onload="loadflag=true">
</BODY>
</html>
The hidden frame is :
<html>
<APPLET CODE="LMSApplet.class" archive="lmsApplet.jar"WID
<param name=cabbase value="lmsApplet.cab">
</APPLET>
<script language="JavaScript">
var loadflag=false;
</script>
<body onload="loadflag=true">
</BODY>
</html>
You've got the applet in the head. Put it in the body.
Cd&
Cd&
ASKER
I put the <body onLoad="X=setInterval('tes tit()',200 )">
tag into the applet page along with the functions and that works nicely.
Nice One
Spunog
tag into the applet page along with the functions and that works nicely.
Nice One
Spunog
Why is it only worth a B grade?
Cd&
Cd&
There could not have been a more correct answer, so I am "correcting" your grade to the earned "A". If you feel I have made an error in judgment, please do let me know.
Moondancer - EE Moderator
Moondancer - EE Moderator
Just a note, was browsing through looking for some info regarding applets and noticed your question.
If you want a more reliable approach, rather than waiting for specified amounts of time and testing for the applet existence you could loop until the applet is loaded. as follows : -
<script>
function Launch()
{
while( parent.hidden.document.app lets.LMSAp plet == null ){}
parent.main.location = parent.hidden.document.LMS Applet.app letMethod( );
}
</script>
hope this helps...
cheers
Bruce
p.s: don't want any points, just a bit surprised no-one else gave you this solution and went for seriously complex overkill on the code.
If you want a more reliable approach, rather than waiting for specified amounts of time and testing for the applet existence you could loop until the applet is loaded. as follows : -
<script>
function Launch()
{
while( parent.hidden.document.app
parent.main.location = parent.hidden.document.LMS
}
</script>
hope this helps...
cheers
Bruce
p.s: don't want any points, just a bit surprised no-one else gave you this solution and went for seriously complex overkill on the code.