Advanced Search

Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Java Applet

  1. #1
    Join Date
    Jan 2009
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Java Applet

    Hi,
    Does anyone know of a script so that a java applet loads last on a web page, or after the page is loaded?
    Than you
    Rick

  2. #2
    Join Date
    Jan 2008
    Posts
    4,103
    Thanks
    18
    Thanked 615 Times in 611 Posts
    Blog Entries
    5

    Default

    Will this work?:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    var applet = 'Applet code here..';
    var doApplet = function(div){
      document.getElementById(div).innerHTML = applet;
    };
    </script>
    </head>
    <body onload="doApplet('app');">
    <div id="app"></div>
    </body>
    </html>

  3. The Following User Says Thank You to Nile For This Useful Post:

    Rick777 (01-25-2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Thanks , but it still did not load the page before the applet loaded up.
    Thank you
    Rick

  5. #4
    Join Date
    Jan 2008
    Posts
    4,103
    Thanks
    18
    Thanked 615 Times in 611 Posts
    Blog Entries
    5

    Default

    Hmm, give this a try:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    var applet = 'Applet code here..';
    var doApplet = function(div){
      (window.onload) ? document.getElementById(div).innerHTML = applet : function() { doApplet(div) };
    };
    </script>
    </head>
    <body onload="doApplet('app');">
    <div id="app"></div>
    </body>
    </html>
    The first one should work though. =/

  6. #5
    Join Date
    Jan 2009
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi I apprecite the help, but both do not let google java script load and show on the page. It still ends up waiting for the applet to load before rendering a page. I know we could create a .js file, but that would not help us on some other pages. It is just for a chat. I guess we have to wait for people to get better comps now.
    Thanks
    Rick

    Here is the page if you are interested where I was trying.
    chatpit.com/teenchat/
    Last edited by jscheuer1; 01-15-2011 at 04:20 AM. Reason: remove hotlink

  7. #6
    Join Date
    Jan 2008
    Posts
    4,103
    Thanks
    18
    Thanked 615 Times in 611 Posts
    Blog Entries
    5

    Default

    You don't have my code anywhere on the page....
    Last edited by jscheuer1; 01-22-2009 at 04:43 PM. Reason: sense

  8. The Following User Says Thank You to Nile For This Useful Post:

    Rick777 (01-25-2009)

  9. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,641
    Thanks
    42
    Thanked 2,897 Times in 2,869 Posts
    Blog Entries
    12

    Default

    Nile's idea should work, but there may be an issue with onload conflicts with other code, or other code also firing onload and if Nile's code were to fire onload, but before other onload code, it would be the same as delaying the onload event for the other code. Often a 0 or low value timeout will be all that's required to delay execution until after other onload code has run. If you do script your Java Applet, it will be unavailable for non-javascript users unless there is a non-javascript fall back for it, like within a <noscript></noscript> tag.

    To deal with the first issue, one should use addEventListener/attachEvent to set the onload event, for the second, a simple time out could be fine (increasing the timeout may be required, though order of execution may still get held up. If so, another strategy may be required for the delay part of this scheme, like determining where on the page to add the script, even splitting execution of the two listeners, as they can behave differently in regard to timing, basic example:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    var doApplet = function(){
      var applet = 'Applet code here..';
      setTimeout(function(){document.getElementById('app').innerHTML = applet;}, 0);
    };
    if (window.addEventListener)
     window.addEventListener('load', doApplet, false);
    else if (window.attachEvent)
     window.attachEvent('onload', doApplet);
    </script>
    </head>
    <body>
    <div id="app"></div>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #8
    Join Date
    Jan 2009
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    You don't have my code anywhere on the page....
    Hi,
    Oh I took it off after I tested both scripts. The fist one showed the most promise, but I it slighty altered the page a bit so I took it off. Would the best solution be to get the applet in a iframe? I do not know how to even do that though. I may just end up putting on a pop up for the java applet so a user can start it when they wish.
    Thank you for all your help.
    Rick

  11. #9
    Join Date
    Jan 2009
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi,
    I just tried this one too:
    http://www.chatpit.com/1test/
    Not a lot off difference, and it also moves an ad to, where I do not wish it to be.
    Thank you
    Rick




    Quote Originally Posted by jscheuer1 View Post
    Nile's idea should work, but there may be an issue with onload conflicts with other code, or other code also firing onload and if Nile's code were to fire onload, but before other onload code, it would be the same as delaying the onload event for the other code. Often a 0 or low value timeout will be all that's required to delay execution until after other onload code has run. If you do script your Java Applet, it will be unavailable for non-javascript users unless there is a non-javascript fall back for it, like within a <noscript></noscript> tag.

    To deal with the first issue, one should use addEventListener/attachEvent to set the onload event, for the second, a simple time out could be fine (increasing the timeout may be required, though order of execution may still get held up. If so, another strategy may be required for the delay part of this scheme, like determining where on the page to add the script, even splitting execution of the two listeners, as they can behave differently in regard to timing, basic example:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    var doApplet = function(){
      var applet = 'Applet code here..';
      setTimeout(function(){document.getElementById('app').innerHTML = applet;}, 0);
    };
    if (window.addEventListener)
     window.addEventListener('load', doApplet, false);
    else if (window.attachEvent)
     window.attachEvent('onload', doApplet);
    </script>
    </head>
    <body>
    <div id="app"></div>
    </body>
    </html>

  12. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,641
    Thanks
    42
    Thanked 2,897 Times in 2,869 Posts
    Blog Entries
    12

    Default

    A good effort. But you have a bit to learn about how to make a valid string variable in javascript, particularly as regards both multi-line string variable values and proper quoting conventions.

    Also, if the applet code is already on the page, as it is in your current effort, writing it to the page later, even if in the same location is more or less no different than having no script for this purpose.

    With me so far?

    Anyways, I was thinking more like this for the script (ask questions if you don't understand the changes from what you had):

    Code:
    <script type="text/javascript">
    var doApplet = function(){
      var applet = '<APPLET NAME="DigiChat" CODEBASE="http://67.19.116.210/DigiChat/DigiClasses/"' +
    'CODE="com.diginet.digichat.client.DigiChatApplet"' +
    'HEIGHT=85 WIDTH=210 ALIGN="MIDDLE"' +
    'ARCHIVE=Client_5_1_0_7.jar MAYSCRIPT>' +
    '<PARAM NAME=cabbase value=Client_5_1_0_7.cab>' +
    '<PARAM NAME=siteID VALUE=253220019>' +
    '<param name="room" value="ThE ChAtPiT">' +
    '<PARAM NAME=MenuItem1 VALUE=Zubee! Online>' +
    '<PARAM NAME=MenuLocation1 VALUE=http://www.zubee.com>' +
    '<PARAM NAME=KickUserHTML VALUE="http://www.chatpit.com/chatrooms.html">' +
    '<PARAM NAME=helpURL VALUE="http://www.zubee.com/">' +
    '<param name="background" value="000000">' +
    '<param name="textcolor" value="00FF00">DigiChat free teen chat rooms require a Java Compatible web browser to view our free teen chat rooms. http://java.sun.com/j2se/1.4.2/download.html</applet>';
      setTimeout(function(){document.getElementById('app').innerHTML = applet;}, 0);
    };
    if (window.addEventListener)
     window.addEventListener('load', doApplet, false);
    else if (window.attachEvent)
     window.attachEvent('onload', doApplet);
    </script>
    And then in the body of the page, where the existing applet code is:

    Code:
    <!-- *** START APPLET CODE *** --><center><div id="app"><noscript>
    <APPLET NAME='DigiChat' CODEBASE='http://67.19.116.210/DigiChat/DigiClasses/'
    CODE='com.diginet.digichat.client.DigiChatApplet'
    HEIGHT=85 WIDTH=210 ALIGN='MIDDLE'
    ARCHIVE=Client_5_1_0_7.jar MAYSCRIPT>
    <PARAM NAME=cabbase value=Client_5_1_0_7.cab>
    <PARAM NAME=siteID VALUE=253220019>
    
    <param name="room" value="ThE ChAtPiT">
    <PARAM NAME=MenuItem1 VALUE=Zubee! Online>
    <PARAM NAME=MenuLocation1 VALUE=http://www.zubee.com>
    <PARAM NAME=KickUserHTML VALUE='http://www.chatpit.com/chatrooms.html'>
    <PARAM NAME=helpURL VALUE='http://www.zubee.com/'>
    <param name="background" value="000000">
    <param name="textcolor" value="00FF00">DigiChat free teen chat rooms require a Java Compatible web browser to view our free teen chat rooms. http://java.sun.com/j2se/1.4.2/download.html</applet></noscript></div>
    The only change there being that the applet itself is now enclosed in <noscript></noscript> tags. This allows non-javascript users to see and use it, and at the same time takes it out of the flow of the document for javascript enabled users, so that for them it will only appear after page load when the script inserts its code to the page.

    Now, we may have a done deal at this point, but there is still the matter of whether or not our timeout delays the applet's initialization in the manner that you desire. If not, let me know because I have a good idea where to go from here to work that last part out.

    Then again, as I say, this may be just the ticket, if so let's leave well enough alone.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  13. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Rick777 (01-25-2009)

Bookmarks

Posting Permissions

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