Link to home
Start Free TrialLog in
Avatar of spunog
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.LMSApplet.appletMethod();
     }
</script>

<BODY onload="Launch()">
</BODY>

</HTML>
Avatar of GorGor1
GorGor1

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.
Avatar of spunog

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 ??
Avatar of knightEknight
try this:


 function Launch()    
 {
    var UNDEFINED; // do not assign
    if ( parent.hidden.document.LMSApplet == UNDEFINED )
       setTimeout('Launch()',1000);  // wait another second
    else  // applet is loaded
       parent.main.location = parent.hidden.document.LMSApplet.appletMethod();
 }
Avatar of spunog

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
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If that does not work maybe you need to show us the code for the hidden page.

Cd&
yeah, the problem might be with this line:

   if ( parent.hidden.document.LMSApplet == 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 )
sorry Cd&, I didn't notice your comments.
Great minds... :^)

Cd&
Avatar of spunog

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"WIDTH=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>
You've got the applet in the head.  Put it in the body.

Cd&
Avatar of spunog

ASKER

I put the <body onLoad="X=setInterval('testit()',200)">
 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&
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
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.applets.LMSApplet == null ){}

       parent.main.location = parent.hidden.document.LMSApplet.appletMethod();
    }
</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.