Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-17-2008, 12:34 AM   PM User | #1
lzr
New to the CF scene

 
Join Date: Oct 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
lzr is an unknown quantity at this point
Question Looking for a javascript to load an applet

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.
lzr is offline   Reply With Quote
Old 10-17-2008, 07:58 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
No, Javascript cannot load an applet. But you could use setTimeout() within a function to delay the loading.

Last edited by Philip M; 10-17-2008 at 08:10 AM..
Philip M is offline   Reply With Quote
Old 10-17-2008, 02:23 PM   PM User | #3
lzr
New to the CF scene

 
Join Date: Oct 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
lzr is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
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?
lzr is offline   Reply With Quote
Old 10-17-2008, 04:31 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Try this (I think it ought to work):-

Code:
<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
Philip M is offline   Reply With Quote
Old 10-17-2008, 05:31 PM   PM User | #5
lzr
New to the CF scene

 
Join Date: Oct 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
lzr is an unknown quantity at this point
[QUOTE=Philip M;740458]
Code:
<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.
lzr is offline   Reply With Quote
Old 10-17-2008, 07:08 PM   PM User | #6
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
[QUOTE=lzr;740477]
Quote:
Originally Posted by Philip M View Post
Code:
<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). Try this.

Code:
<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 M is offline   Reply With Quote
Old 10-17-2008, 09:28 PM   PM User | #7
lzr
New to the CF scene

 
Join Date: Oct 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
lzr is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post

Code:
<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.
lzr is offline   Reply With Quote
Old 10-18-2008, 08:26 AM   PM User | #8
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Old 10-19-2008, 02:56 PM   PM User | #9
lzr
New to the CF scene

 
Join Date: Oct 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
lzr is an unknown quantity at this point
Philip,
Thanks for the attempt anyway,
Lzr
lzr is offline   Reply With Quote
Old 10-19-2008, 03:08 PM   PM User | #10
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
perhaps u should put the thing into IFRAME,
have no idea, it might work.
BubikolRamios is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:54 PM.


Advertisement
Log in to turn off these ads.