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

168
Vistas
Can I call function from previously loaded javascript on android WebView?

I'm loading javascript into a WebView from the Activity, the webpage being shown is external. The problem is that I'm not able to call a fucntion that I've previously loaded, neither access variables values. When I do webView.loadUrl("""var a = 0; function foo(){a = 1;}""") the code executes perfectly (this code is only an example). But if I then do webView.loadUrl("""foo();""") It gives an "foo not defined" error. And yes, I'm loading the js after the page has finished loading.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Have you called setJavaScriptEnabled(true).

Also, have you tried loading the function like this

webView.loadUrl(
            """javascript:(function() {
            // my js code
            })()"""
)
about 4 years ago · Juan Pablo Isaza Denunciar
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