I am trying to call a JavaScript function from a JavaFX WebView on a JavaFX button click event.
I am using the following code, but it is not working:
try {
  File file = new File("F:\\inputfile\\hello.htm");
  WebEngine webengine = webview.getEngine();
  webengine.load(file.toURI().toURL().toString());
} catch(Exception ex) {
  ex.printStackTrace();
}
On any button click I want to execute the test() JavaScript method in the html file:
webengine.executeScript("test()");
And the JavaScript method in html file is:
<script language="javascript">
  function test()
  {
    window.scrollBy(0, 20); 
  }
</script>
 
     
     
    