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

时间:2013-12-17 10:49:51

标签: internet-explorer javafx

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

一个样本: 我正在做的是退出应用程序(按下按钮时)(请参阅下面的java代码)并在JS上调用launchit ..

我的HTML:

<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);
    }
}

1 个答案:

答案 0 :(得分:1)

最后我解决了..

我只需通过调用

在运行时动态创建另一个持有者(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>

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

祝你好运,'。