Solved

Applet not loaded in time for call

Posted on 2002-04-22
15
293 Views
Last Modified: 2008-03-17
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>
0
Comment
Question by:spunog
  • 5
  • 4
  • 3
  • +3
15 Comments
 
LVL 1

Expert Comment

by:GorGor1
ID: 6959693
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.
0
 

Author Comment

by:spunog
ID: 6959716
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 ??
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6959789
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();
 }
0
 

Author Comment

by:spunog
ID: 6959851
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 ...
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 100 total points
ID: 6959898
Try it this way:

In the page with the applet put this in the head:
<script language="JavaScript"> var loadflag=false; </script>
and in the body tag: <body onload="loadflag=true">


then for the main page:
function testit()
{
if (top.frames['hidden'].loadflag)
{
  clearInterval(X);
  Launch();
}


and for the body tag:
<body onLoad="X=setInterval('testit()',200)">


Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6959904
If that does not work maybe you need to show us the code for the hidden page.

Cd&
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6959905
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 )
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Expert Comment

by:knightEknight
ID: 6959909
sorry Cd&, I didn't notice your comments.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6959955
Great minds... :^)

Cd&
0
 

Author Comment

by:spunog
ID: 6959981
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>
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6960005
You've got the applet in the head.  Put it in the body.

Cd&
0
 

Author Comment

by:spunog
ID: 6960128
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
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6960145
Why is it only worth a B grade?

Cd&
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6960815
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
0
 
LVL 1

Expert Comment

by:hurtlingturtle
ID: 8136878
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.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now