2

Is it possible to call JavaFx application from javaScript? Now i'm able to call an html file from javaFX using

  webview = new WebView();
  webview.setVisible(true);
  webengine = webview.getEngine();
  webengine.setJavaScriptEnabled(true);
  File file = new File("C:\\sample.html");
  System.out.println(file.exists() + " file exitence");
  webengine.load(file.toURI().toURL().toString());

if possible please help me. i'm new to java and JavaFx.

2

1 Answer 1

1

In JS: alert("HEAD;DATA");

In Java:

WebView webView = new WebView();
final WebEngine engine = webView.getEngine();

engine.setOnAlert(new EventHandler<WebEvent<String>>() {
    public void handle(WebEvent<String> e) {
        String[] infs = e.getData().split(";");

        if(infs[0].equals("HEAD")){
            System.out.println(infs[1]);
        }
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.