如上所述,一旦用户单击更改页面的内容,使用 JavaFX 的脚本将不再起作用。
你好.html
<div onclick="app.byeBye()">bye</div>
再见.html
<div onclick="app.hello()">hello</div>
JavaApp.class
public class JavaApp{
public void hello(){
//process some stuff here
setURL("/hello.html");
}
public void byeBye(){
//process some stuff here
setURL("/byebye.html");
}
private void setURL(final String uriString){
Platform.runLater(new Runnable(){
public void run(){
JSObject win = (JSObject) webViewPanel.getWebEngine().executeScript("window");
win.setMember("app", new JavaApp());
webViewPanel.loadURL(Browser.class.getResource(uriString).toExternalForm());
}
});
}
}
我必须怎么做才能解决这个问题?