Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
JavaFX JSBridge no funciona después de cargar la página

Tengo un problema extraño; JSBridge no funciona después de que se carga la página, pero sí cuando se hace clic en el botón.

Sitio de prueba:

 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> </head> <body bgcolor="#A0BEC4"> <input type="button" value="PLAY" onclick="play()"><br><br> <script> window.onload = function() { //does not work stb.play("hello3"); } function play() { // work stb.play("hello2"); } window.addEventListener('load', (event) => { stb.play("hello4"); //does not work }); stb.play("hello"); //does not work function checkJSBridge(){ // !!! WORK !!! if (typeof (stb.play) === "function") { stb.play("WORK"); clearTimeout(bridge_timer); } } let bridge_timer = setTimeout(checkJSBridge, 1000); </script> </body> </html>

Mi código (JavaFX 18.0.1 y JDK 18.0.1.1):

 private WebEngine webEngine = webView.getEngine(); private Worker<?> engineWorker = webEngine.getLoadWorker(); private JSBridge bridge = new JSBridge(); @Override public final void start(Stage stage) throws Exception { engineWorker.stateProperty().addListener(new ChangeListener<Worker.State>() { @Override public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) { if (newState == State.SUCCEEDED) { JSObject jsobj = (JSObject) webEngine.executeScript("window"); jsobj.setMember("stb", bridge); } } }); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!