title: How to call a JavaScript function from a JavaFX WebView on Button click?
body: <p>I am trying to call a JavaScript function from a JavaFX <a href="http://docs.oracle.com/javafx/2/api/javafx/scene/web/WebView.html" rel="noreferrer">WebView</a> on a JavaFX button click event.</p>
  
  <p>I am using the following code, but it is not working:</p>
  
  <pre><code>try {
    File file = new File("F:\\inputfile\\hello.htm");
  
    WebEngine webengine = webview.getEngine();
    webengine.load(file.toURI().toURL().toString());
  } catch(Exception ex) {
    ex.printStackTrace();
  }
  </code></pre>
  
  <p>On any button click I want to execute the <code>test()</code> JavaScript method in the html file:</p>
  
  <pre><code>webengine.executeScript("test()");
  </code></pre>
  
  <p>And the JavaScript method in html file is:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
    function test()
    {
      window.scrollBy(0, 20); 
    }
  &lt;/script&gt;
  </code></pre>