...

View Full Version : Looking for a javascript to load an applet



lzr
10-17-2008, 12:34 AM
Hi,
When an applet is loading the browser freezes for several seconds during which the page stops loading and scrollers don't work either. I understand it is a general issue with the applets. I wonder if there is a javascript that would cause applet to start loading only after the entire page is loaded?
The original script that opens the applet looks like:
<div><applet code="whatever.class"></applet></div>
Thanks.

Philip M
10-17-2008, 07:58 AM
No, Javascript cannot load an applet. But you could use setTimeout() within a function to delay the loading.

lzr
10-17-2008, 02:23 PM
No, Javascript cannot load an applet. But you could use setTimeout() within a function to delay the loading.

Philip,
Thanks for reply. I am not an expert on coding (the applet was provided by someone else). Do I need to modify the .class program to do this, or I can set timeout externally? If it can be a separate script, would it be too much to ask for an exact code?

Philip M
10-17-2008, 04:31 PM
Try this (I think it ought to work):-


<script type = "text/javascript">
function loadApplet() {
if (navigator.javaEnabled()) {
document.write('<div><applet code="whatever.class"></applet></div>');
}
}
window.setTimeout("loadApplet",5000); // 5 seconds delay
</script>


A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx

lzr
10-17-2008, 05:31 PM
[QUOTE=Philip M;740458]

<script type = "text/javascript">
function loadApplet() {
if (navigator.javaEnabled()) {
document.write('<div><applet code="whatever.class"></applet></div>');
}
}
window.setTimeout("loadApplet",5000); // 5 seconds delay
</script>

Unfortunately, something's got to be wrong here-it does not load the applet at all.

Philip M
10-17-2008, 07:08 PM
[QUOTE=Philip M;740458]

<script type = "text/javascript">
function loadApplet() {
if (navigator.javaEnabled()) {
document.write('<div><applet code="whatever.class"></applet></div>');
}
}
window.setTimeout("loadApplet",5000); // 5 seconds delay
</script>

Unfortunately, something's got to be wrong here-it does not load the applet at all.

Sorry, I left something out (brackets). :o Try this.


<script type = "text/javascript">
function loadApplet() {
if (navigator.javaEnabled()) {
document.write('<div><applet code="whatever.class"></applet></div>');
}
}
window.setTimeout("loadApplet()",5000); // 5 seconds delay
</script>

lzr
10-17-2008, 09:28 PM
<script type = "text/javascript">
function loadApplet() {
if (navigator.javaEnabled()) {
document.write('<div><applet code="whatever.class"></applet></div>');
}
}
window.setTimeout("loadApplet()",5000); // 5 seconds delay
</script>

Philip,
Thanks for your help. It's getting closer :) it loads applet with delay as intended, except when applet is loading it replaces entire content of the page, i.e. only applet remains on the page.

Philip M
10-18-2008, 08:26 AM
Ah, that is because document.write statements must be run before the page finishes loading. But I always thought that this means that they must be either in the body of the page or in functions called from the body of the page (as here). Obviously the delay allows the page to complete loading. :(

I am afraid that I am not able to make any more suggestions - but perhaps someone else could suggest another method or technique.

lzr
10-19-2008, 02:56 PM
Philip,
Thanks for the attempt anyway,
Lzr

BubikolRamios
10-19-2008, 03:08 PM
perhaps u should put the thing into IFRAME,
have no idea, it might work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum