Disable JavaScript from running in JavaFX WebView

java, javafx, javascript, webview

Solution

You have to set Javascript disabled on the `WebEngine` itself that the WebView controls.

WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
webEngine.setJavaScriptEnabled(false);

Problem

I would like to know if JavaScript can be disabled in `WebView` of JavaFX. I have searched the web but cant get any information about this. The link in Oracle website says that JavaScript can be enabled and disabled but can't find any documentation.

Original source