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

165
Views
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 answers
Answer question

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 Report
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!