1
Papelera de reciclaje General / Re: Best method for waiting on JavaFX2 WebEngine to load before executing my JavaScr
« Posteado: October 02, 2023, 03:32:36 AM »
Hey there,
A reliable way to wait for JavaFX2 WebEngine to load before executing JavaScript is by utilizing the WebEngine's getLoadWorker() method in conjunction with an event listener.
Here's a snippet of code to demonstrate:
This code sets up a listener to wait for the SUCCEEDED state, indicating that the page has finished loading. Once that happens, your JavaScript code can be safely executed.
Hope this helps! Let me know on OGInstagram Apk if you have further questions.
Cheers,Amir_shami
A reliable way to wait for JavaFX2 WebEngine to load before executing JavaScript is by utilizing the WebEngine's getLoadWorker() method in conjunction with an event listener.
Here's a snippet of code to demonstrate:
Code: [Select]
WebEngine webEngine = webView.getEngine();
webEngine.getLoadWorker().stateProperty().addListener(
(observable, oldState, newState) -> {
if (newState == Worker.State.SUCCEEDED) {
// Your JavaScript code here
}
}
);
webEngine.load("yourURL");
Hope this helps! Let me know on OGInstagram Apk if you have further questions.
Cheers,Amir_shami