使用JavaFX小程序:
我用document.getElementById("APPLET_ID")得到的javascript对象在Windows下没有包属性。我用最新的IE8、FF和Chrome在Windows XP上运行我的测试,但在Windows7上也存在同样的问题。
在带有JRE7u7 x64的Ubuntu下,没有这样的问题。
下面是我的测试代码:
package test;
import netscape.javascript.JSObject;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
private JSObject js;
TextField tf;
@Override
public void start(Stage primaryStage) {
js = this.getHostServices().getWebContext();
HBox hb = new HBox();
Scene s = new Scene(hb, 400, 400);
tf = new TextField("MAIN");
primaryStage.setScene(s);
hb.getChildren().add(tf);
primaryStage.show();
runTest();
}
public static void main(String[] args) {
launch(args);
}
void runTest(){
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Platform.runLater(
new Runnable() {
@Override
public void run() {
tf.setText("" + js.eval("document.getElementById('applet_id').Packages == null"));
}
}
);
}
}).start();
}
}在所有浏览器中,在Ubuntu JRE7u7x64下显示"false“,在Windows和Ubuntu JRE7u21下显示"true”。
正如JavaFX2部署文档页面所显示的那样,我使用的方法是正确的,它看起来像是一个JRE。你对此有什么看法?
http://docs.oracle.com/javafx/2/deployment/javafx_javascript.htm。
发布于 2013-06-25 01:09:36
看起来这是从7u21开始的预期变化:http://www.oracle.com/technetwork/java/javase/7u21-relnotes-1932873.html这个包属性没有更多的工作。
因此,如果您需要从JS回调到applet,则必须直接访问它的方法。
并使用Trusted-Library清单属性来避免警告。
但是在使用Trusted-Library时,你不能做你想做的事情。例如,如果您使用Axis2 use服务。
因此您必须使用仅受信任清单属性来执行此操作。但这会禁止您从JS调用方法。
简单的解决方法:让一个线程定期检查JS回调队列并处理它们。这是痛苦的,可怕的POJO,但它是有效的。
因此,致Oracle :谢谢
你知道Adobe吗?听说他们有很好的东西。我很生气。
https://stackoverflow.com/questions/16799694
复制相似问题