无法使用 Internet Explorer 第二次启动 JavaFX Web 应用程序(重新启动)



当我尝试在网络上重新启动JavaFX应用程序(第二次调用)时,IE出现问题..这只发生在IE中。问题是我收到两次证书通知,但我期望的是一个..

其中一个例子:我正在做的是从应用程序退出(按下按钮时)(请参阅下面的Java代码)并在JS上调用launchit..

我的网页 :

<html><head>
<script language="JavaScript" src="./web-files/dtjava.js"></script>
<script>


    function launchit(){
 dtjava.embed(
            {
                url : 'Simple_reLaunchJFX.jnlp',
                placeholder : 'javafx-app-placeholder',
                width : 800,
                height : 600,
                jnlp_content : 'PD94bWwgdmVyc2lvbj0iMS4w..........pubHA+DQo='
            },
            {
                javafx : '2.2+'
            },
            {}
        );

    dtjava.addOnloadCallback(javafxEmbed);
    }
</script>
</head><body>
<h2>__</h2>

  <a href='#' onclick="launchit();">start JFX</a><br><hr><br>
  <br>
  <!-- Applet will be inserted here -->
  <div id='javafx-app-placeholder'></div>
</body></html>

爪哇岛:

package simple_relaunchjfx;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
 *
 * @author maher
 */
public class Simple_reLaunchJFX extends Application {
    @Override
    public void start(final Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");

        StackPane root = new StackPane();
        root.getChildren().add(btn);
        Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();

        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
                try {
                    primaryStage.close();
                    Platform.exit();
                    System.exit(0);
                } catch (Exception ex) {
                    System.err.println("error " + ex.getMessage());
                }
            }
        });
    }
    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}

最后我解决了它..

我只是通过调用在运行时动态创建另一个持有者 (div)

addElement(count);

并致电

dtjava.addOnloadCallback(javafxEmbed);

javafxEmbed 引用了持有者div 的新 ID

这将导致多个持有者 (div) @ 同时.我试图删除以前的持有人.但这并不能解决问题。使用IE它显示2个提示..

但这还不是结束:)我只是在创建JavaFX的新实例后隐藏了以前的div

hidepreviousElement(count-1)

我将所有方法合二为一:

function launchit(){
    count=count+1;
    addElement(count);
    dtjava.addOnloadCallback(javafxEmbed);
    hidepreviousElement(count-1);
    }

我知道有变体方法如何添加/删除..我只是使用被认为与常见浏览器IE/FF/Chrome兼容的内容。

<html><head>
<script language="JavaScript" src="./web-files/dtjava.js"></script>
<script>
var count=1;
   function javafxEmbed() {
        dtjava.embed(
            {
                url : 'Simple_reLaunchJFX_1_002.jnlp',
                placeholder : 'javafx-app-placeholder'+count,
                width : 800,
                height : 600,
                jnlp_content : 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxqbmxwIHNwZWM9IjEuMCIgeG1sbnM6amZ4PSJodHRwOi8vamF2YWZ4LmNvbSIgaHJlZj0iU2ltcGxlX3JlTGF1bmNoSkZYXzFfMDAyLmpubHAiPg0KICA8aW5mb3JtYXRpb24+DQogICAgPHRpdGxlPlNpbXBsZV9yZUxhdW5jaEpGWF8xXzAwMjwvdGl0bGU+DQogICAgPHZlbmRvcj5tYWhlcjwvdmVuZG9yPg0KICAgIDxkZXNjcmlwdGlvbj5udWxsPC9kZXNjcmlwdGlvbj4NCiAgICA8b2ZmbGluZS1hbGxvd2VkLz4NCiAgPC9pbmZvcm1hdGlvbj4NCiAgPHJlc291cmNlcz4NCiAgICA8amZ4OmphdmFmeC1ydW50aW1lIHZlcnNpb249IjIuMisiIGhyZWY9Imh0dHA6Ly9qYXZhZGwuc3VuLmNvbS93ZWJhcHBzL2Rvd25sb2FkL0dldEZpbGUvamF2YWZ4LWxhdGVzdC93aW5kb3dzLWk1ODYvamF2YWZ4Mi5qbmxwIi8+DQogIDwvcmVzb3VyY2VzPg0KICA8cmVzb3VyY2VzPg0KICAgIDxqMnNlIHZlcnNpb249IjEuNisiIGhyZWY9Imh0dHA6Ly9qYXZhLnN1bi5jb20vcHJvZHVjdHMvYXV0b2RsL2oyc2UiLz4NCiAgICA8amFyIGhyZWY9IlNpbXBsZV9yZUxhdW5jaEpGWF8xXzAwMi5qYXIiIHNpemU9IjIwODQ5IiBkb3dubG9hZD0iZWFnZXIiIC8+DQogIDwvcmVzb3VyY2VzPg0KPHNlY3VyaXR5Pg0KICA8YWxsLXBlcm1pc3Npb25zLz4NCjwvc2VjdXJpdHk+DQogIDxhcHBsZXQtZGVzYyAgd2lkdGg9IjgwMCIgaGVpZ2h0PSI2MDAiIG1haW4tY2xhc3M9ImNvbS5qYXZhZngubWFpbi5Ob0phdmFGWEZhbGxiYWNrIiAgbmFtZT0iU2ltcGxlX3JlTGF1bmNoSkZYXzFfMDAyIiA+DQogICAgPHBhcmFtIG5hbWU9InJlcXVpcmVkRlhWZXJzaW9uIiB2YWx1ZT0iMi4yKyIvPg0KICA8L2FwcGxldC1kZXNjPg0KICA8amZ4OmphdmFmeC1kZXNjICB3aWR0aD0iODAwIiBoZWlnaHQ9IjYwMCIgbWFpbi1jbGFzcz0ic2ltcGxlX3JlbGF1bmNoamZ4LlNpbXBsZV9yZUxhdW5jaEpGWCIgIG5hbWU9IlNpbXBsZV9yZUxhdW5jaEpGWF8xXzAwMiIgLz4NCiAgPHVwZGF0ZSBjaGVjaz0iYWx3YXlzIi8+DQo8L2pubHA+DQo='
            },
            {
                javafx : '2.2+'
            },
            {
            }
        );
    } 

    function launchit(){
    count=count+1;
    addElement(count);
    dtjava.addOnloadCallback(javafxEmbed);
    hidepreviousElement(count-1);
    }

function addElement(cc) {
  var ni = document.getElementById('ccc');  
  var newdiv = document.createElement('div');
  var divIdName = 'javafx-app-placeholder'+cc;
  newdiv.setAttribute('id',divIdName);
  ni.appendChild(newdiv);
}
function hidepreviousElement(cc){
var ni = document.getElementById('javafx-app-placeholder'+cc);  
ni.style.display = 'none';
}
</script>
</head><body>
<h2>__</h2>

  <a href='#' onclick="launchit();">start JFX</a><br><hr><br>

  <br>
  <!-- Applet will be inserted here -->
  <div id='ccc'><div id='javafx-app-placeholder1'></div></div>
</body></html>

我希望这对某人有所帮助并节省他/她的时间..

祝你好运,'。

相关内容

  • 没有找到相关文章

最新更新