How to delay an applet until page is loaded

  • lzr
  • Novice
  • Novice
  • No Avatar
  • Joined: May 09, 2008
  • Posts: 18
  • Status: Offline

Post September 19th, 2008, 6:36 am

Hi,
I have an applet, which is loading slow and is causing the whole page appearing with large delay. Is it possible to add a script that delays applet loading (and respectively delay downloading from the server the files associated with this applet) until the rest of the page has been loaded? Or at least to have some top components of the page load progressively? The page itself consist just of few tables with text and links, the whole html file is 8kb.
The script for the applet looks like:
Code: [ Download ] [ Select ]
<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715">
</applet>
  1. <applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715">
  2. </applet>


Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 19th, 2008, 6:36 am

  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post September 19th, 2008, 6:46 am

Where you have that now, put the following code in place of it.

Code: [ Download ] [ Select ]
<div id="applet" style="height:350px; width:715px;"></div>


Before the </body> tag, place the following code.

Code: [ Download ] [ Select ]
<script type="text/javascript">//<![CDATA[
document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
//]]></script>
  1. <script type="text/javascript">//<![CDATA[
  2. document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
  3. //]]></script>
Why yes, yes I am.
  • lzr
  • Novice
  • Novice
  • No Avatar
  • Joined: May 09, 2008
  • Posts: 18
  • Status: Offline

Post September 19th, 2008, 8:31 am

joebert wrote:
Code: [ Download ] [ Select ]
<script type="text/javascript">//<![CDATA[
document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
//]]></script>
  1. <script type="text/javascript">//<![CDATA[
  2. document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
  3. //]]></script>


joebert,
Thanks for reply. It almost works... except now applet is not loading at all. IE6 shows the following error: "Unterminated string constant". W3 code validator sites error in the line </applet>:
"end tag for element "APPLET" which is not open".
This is weird since applet *is* open.
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post September 19th, 2008, 8:37 am

Yikes.

Try this one instead.

Code: [ Download ] [ Select ]
<script type="text/javascript">//<![CDATA[
document.getElementById('applet').innerHTML = '<app' + 'let code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"> </app' + 'let>';
//]]></script>
  1. <script type="text/javascript">//<![CDATA[
  2. document.getElementById('applet').innerHTML = '<app' + 'let code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"> </app' + 'let>';
  3. //]]></script>
Why yes, yes I am.
  • lzr
  • Novice
  • Novice
  • No Avatar
  • Joined: May 09, 2008
  • Posts: 18
  • Status: Offline

Post September 19th, 2008, 8:50 am

joebert wrote:
Code: [ Download ] [ Select ]
<script type="text/javascript">//<![CDATA[
document.getElementById('applet').innerHTML = '<app' + 'let code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"> </app' + 'let>';
//]]></script>
  1. <script type="text/javascript">//<![CDATA[
  2. document.getElementById('applet').innerHTML = '<app' + 'let code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"> </app' + 'let>';
  3. //]]></script>


Now IE does not show error on the page, but the applet still does not load. W3 says: "end tag for element "APP" which is not open".
Lzr
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post September 19th, 2008, 10:04 am

Is there a missing <param> ?
Why yes, yes I am.
  • lzr
  • Novice
  • Novice
  • No Avatar
  • Joined: May 09, 2008
  • Posts: 18
  • Status: Offline

Post September 19th, 2008, 2:33 pm

joebert wrote:
Is there a missing <param> ?


joeberg,

No, not as far as I know. It was not me who created this applet, but it does work when I call it directly, i.e. not via a javascript.
Lzr
  • lzr
  • Novice
  • Novice
  • No Avatar
  • Joined: May 09, 2008
  • Posts: 18
  • Status: Offline

Post September 20th, 2008, 8:07 pm

joebert wrote:
Code: [ Download ] [ Select ]
<script type="text/javascript">//<![CDATA[
document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
//]]></script>
  1. <script type="text/javascript">//<![CDATA[
  2. document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
  3. //]]></script>


I can't explain why it did not work for me first, maybe I did not copy the code correctly, but it does work. Thanks for your help.
Lzr
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post September 20th, 2008, 10:08 pm

Well that's good, because I was running out of ideas. :)
Why yes, yes I am.
  • lzr
  • Novice
  • Novice
  • No Avatar
  • Joined: May 09, 2008
  • Posts: 18
  • Status: Offline

Post October 16th, 2008, 10:30 am

joebert wrote:
...
Code: [ Download ] [ Select ]
<div id="applet" style="height:350px; width:715px;"></div>

...
Code: [ Download ] [ Select ]
<script type="text/javascript">//<![CDATA[
document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
//]]></script>
  1. <script type="text/javascript">//<![CDATA[
  2. document.getElementById('applet').innerHTML = '<applet code="Generator.class" archive="Generator.jar, Ph14English.jar" height="350" width="715"></applet>';
  3. //]]></script>


Hi again, joebert,
Sorry for troubling you, just thought you might have more ideads on this. The code you suggested does work in the sense it loads the applet, but it does not seem to delay the applet until the whole page is loaded as was meant. What I see is the top portion of the page above <div id="applet"></div> is loaded first, then my browser freezes for a few seconds, then the applet along with the rest of the page are appearing practically simultaneously. I did not originally noticed this since after the applet is loaded once, the next time it loads fast- I had to clear the browser's cache after each test.
lzr

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 236 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.