Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    lzr
    lzr is offline
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.

  • #3
    lzr
    lzr is offline
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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

  • #5
    lzr
    lzr is offline
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    [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.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    [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>

  • #7
    lzr
    lzr is offline
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.

  • #9
    lzr
    lzr is offline
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Philip,
    Thanks for the attempt anyway,
    Lzr

  • #10
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,960
    Thanks
    120
    Thanked 76 Times in 76 Posts
    perhaps u should put the thing into IFRAME,
    have no idea, it might work.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •