What I'm trying to implement is essentially the cancel button of a browser but using JavaFX's webview. This is the code I have so far:
Worker<Void> loadWorker = webView.getEngine().getLoadWorker();
if (loadWorker != null) {
Platform.runLater(() -> loadWorker.cancel());
}
but it sometimes work and sometimes doesn't.
What's the proper way of canceling the webview/webengine task of loading a page?
After canceling the webEngine
task, can you try with setting the content of the webEngine
to null
:
webView.getEngine().load(null);
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