Until Java 8u51, the following worked fine:
<script src="javascript.js"></script>
javascript.js
using webView.getEngine().executeScript()
After switching to 8u60 however, it no longer works:
Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: TypeError: undefined is not a function
So the file javascript.js
is no longer loaded. It works when started from an IDE, where JavaScript file just lies on the file system. However, it no longer works when the application is packaged and therefore javascript.js
is inside a JAR file.
Any idea what has changed and how this can be fixed?
Since Java 8u60, local javascript files referenced in html files are not executed anymore in the WebView. When running the program with an older version, it still works. I found no information that this change in behaviour was intended by Oracle.
As a workaround you can either place the javascript code directly into the HTML file, or load in java the contents of the javascript file into a String and execute it with webView.getEngine().executeScript()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With