Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda