加载java applet上的DOM加载 [英] loading java applet on DOM load

查看:147
本文介绍了加载java applet上的DOM加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了很多,但可能我正在搜索错误的字符串。 Java小程序正在向我的页面提供活动位,java小程序访问我的页面上的输入字段,并将信息放在

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">

然后它调用一个JavaScript函数,页面上说LivePicker(),然后它只是拾取一个值

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;

我所面临的问题是,这样做很好,但有时在firebug控制台中,它会给出诸如LivePicker之类的错误没有定义,而LivePicker将在页面上工作得很好,有时它会给F1没有定义,而我的时钟将工作正常。所有这些错误都显示在页面加载中。

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依次放置数据,首先放置数据,然后调用js函数来处理它。这在使用最少的HTML和JS的测试页上工作得很好,但是当我将它集成到我的应用程序中时,它使用了很多来自YUI的组件和很多我自己的JS代码(现在已经明确缩小),它会给出这些错误。有一点我想补充一点,在缩小之前,这些错误很有可能,但在JS和CSS缩小之后,页面加载时间减少了一半,这些错误的外观也减少了一半。

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.

我怀疑这是由于在页面加载时,applet尝试操纵尚未准备好的DOM。有没有什么可以阻止小程序等到DOM完全加载?我尝试了YUI的window.onload和onDOMReady函数,它们似乎没有任何效果。

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.

可以帮助吗?

推荐答案

您可以尝试使用setTimeout来延迟执行

you could try using setTimeout to delay execution

https://developer.mozilla.org/en/DOM/window.setTimeout

或jQuery库也可以帮助文档对象上的ready事件

or the jQuery library could also help out with the ready event on the document object

http://docs.jquery.com/Events/ready#fn

这篇关于加载java applet上的DOM加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆