在 IE9 和 IE9 平台预览版中,我无法再从 Java Applet 调用 Javascript 方法
在早期版本的 IE 和 Firefox 中,我可以从运行在同一页面上的 Java Applet 调用 JavaScript 中的 methodFoo。在 IE9 中,这不再起作用。是否有一些额外的步骤或适用于 IE9 的不同方法?
我的 Java Applet 包含
import netscape.javascript.JSObject;
...
private transient JSObject jso;
...
public void init() {
...
jso = JSObject.getWindow(this);
... }
public void CalledFromSecondaryThread(){
...
jso.call("methodFoo", object_to_pass);
... }
我的 Html 页面包含
...
<object style="height: 1px;width: 650px;" classid = "clsid:CAFEEFAC-0016-0000-0011-ABCDEFFEDCBA" codebase = "http://java.sun.com/update/1.6.0/jinstall-6u11-windows-i586.cab#Version=6,0,0,11" id="AppletControl">
<param name="java_arguments" value="-Xmx256m" />
<param name = "CODE" value = "com.namespace.Applet.class" />
<param name = "archive" value = "./lib/applet.jar" />
<param name = "type" value = "application/x-java-applet;version=1.6" />
<param name = "scriptable" value="true" />
<param name = "mayscript" value="true" />
</object>
...
<script type="text/JavaScript" src="js/script.js"></script>
...
并且 script.js 包含
function methodFoo(object_to_pass){
//doStuff
}
从 jso.call 收到的异常是
netscape.javascript.JSException: No such method "methodFoo" on JavaScript object
In prior versions of IE and in Firefox, I am able to call methodFoo in JavaScript from my Java Applet running on the same page. In IE9, this no longer works. Is there some additional step, or a different way of doing this that will work for IE9?
My Java Applet contains
import netscape.javascript.JSObject;
...
private transient JSObject jso;
...
public void init() {
...
jso = JSObject.getWindow(this);
... }
public void CalledFromSecondaryThread(){
...
jso.call("methodFoo", object_to_pass);
... }
My Html page contains
...
<object style="height: 1px;width: 650px;" classid = "clsid:CAFEEFAC-0016-0000-0011-ABCDEFFEDCBA" codebase = "http://java.sun.com/update/1.6.0/jinstall-6u11-windows-i586.cab#Version=6,0,0,11" id="AppletControl">
<param name="java_arguments" value="-Xmx256m" />
<param name = "CODE" value = "com.namespace.Applet.class" />
<param name = "archive" value = "./lib/applet.jar" />
<param name = "type" value = "application/x-java-applet;version=1.6" />
<param name = "scriptable" value="true" />
<param name = "mayscript" value="true" />
</object>
...
<script type="text/JavaScript" src="js/script.js"></script>
...
and script.js contains
function methodFoo(object_to_pass){
//doStuff
}
The Exception received from jso.call is
netscape.javascript.JSException: No such method "methodFoo" on JavaScript object
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 IE 9 Beta 中的错误 620646 - 已在 RC 和更新版本的 IE9 中修复
Microsoft 的错误报告
This was bug 620646 in IE 9 Beta - and has been fixed in the RC and newer versions of IE9
Bug Report at Microsoft