Jump to content

java applet load only when DOM got loaded


hammadtariq

Recommended Posts

Hello,

        I searched for it a lot but probably I am searching wrong strings. A Java applet is feeding live bits into my pages, java applet accesses the input fields on my page and places the information

 

<input type="hidden" id="F1" value="Nothing Yet">

 

and then it calls a javascript functionon the page say LivePicker() and then it simply picks up a value

 

var ClockVal = document.getElementById("F1").value;
document.getElementById("ICSCLOCK").innerHTML = ClockVal;

 

The problem I am facing is, this works fine but sometimes in firebug console it give errors like LivePicker is not defined, while LivePicker would be working perfectly fine on the page while sometimes it will give F1 is not defined, while my clock would be working fine. All of these errors appear at page load.

 

Java applet places the data sequentially, it first place the data and then calls the js function to process it. That works perfectly fine on test pages with minimum HTML and JS but when I integrate it to my application, which uses a lot of components from YUI and a lot of my own JS code (which is now minified obviously), it give these errors. One thing I would like to add, before minification, these errors were a lot likely but after minification of JS and CSS, the page load time is reduced to half and the appearence of these errors are reduced to half as well.

 

I am suspecting this is due to, on page load, applet tries to manipulate the DOM which is not ready yet. Is there anything, which could stop the applet to wait until the DOM is fully loaded? I tried window.onload and onDOMReady function of YUI, they seem to make no effect at all.

 

Can any one help?

Link to comment
Share on other sites

I reverted the code because it was not working but quickly it was a javascript function:

 

function loadingJava(){
         document.write("appletcod-goes-here");
}
window.onload = loadingJava;

 

Thought it would work. I have other script tags on the pages as well and one of them appear consistenly, that is related to tabview component of YUI and it uses window.onload event as well. So, using onload is not a good idea, but I tested this on a page where there was no onload function already but that didnt worked either.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.