Solved

Applet not loaded in time for call

Posted on 2002-04-22
15
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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
 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

752 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