我正在使用 JSObject.call 从我的小程序中调用 Java Script API。这对于 Chrome Firefox 和 Internet Explorer v7 和 v8 非常有用。使用 v9 和 v10 的小程序无法正常工作。我可以看到它在调用 JSObject.call 时失败,并且无法执行从 Java Script(在 applet 中实现)调用的任何 API(例如 myMethod)。
从小程序 -
public void paint(Graphics g)
{
if (!appletInit)
{
try
{
window = JSObject.getWindow(this);
window.call("MyAppletLoad", new Object[0]);
}
catch (Exception e)
{
e.printStackTrace();
}
}
appletInit = true;
}
在资源管理器调试控制台中,我看到了这个错误:
SCRIPT438:对象不支持属性或方法“myMethod”
在 Java 控制台中,我看到了这个异常:
Exception in thread "AWT-EventQueue-3" netscape.javascript.JSException: Unspecified error invoking method or accessing property "onAppletLoad"
at sun.plugin2.main.client.MessagePassingJSObject.newJSException(Unknown Source)
at sun.plugin2.main.client.MessagePassingJSObject.waitForReply(Unknown Source)
at sun.plugin2.main.client.MessagePassingJSObject.call(Unknown Source)
at SmartConfig.paint(SmartConfig.java:239)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
第 239 行是使用 JSObject.call 的行:
window.call("MyAppletLoad", new Object[0]);
如果我将浏览器模式设置为兼容性视图或旧版本(8 或更低版本),它运行良好。是 IE9\10 错误吗?与 IE8 相比有何变化?我该如何解决这个错误?请协助。谢谢!