简体   繁体   中英

how do you call javascript from native android code

i know that, from this website, in order to call javascript function of a webpage from android is webview.loadUrl("javascript:CALLME()")

my question is, i need to first load the page first where i have my javasctip function CALLME() defined right?

in other words

i should have

  webview.loadUrl("http://myweb.com/web.html)  // web.html has javascript CALLME() defined
  webview.loadUrl("javascript:CALLME()");

right??

apparently, CALLME() is not getting called

please help

你检查了吗?

 webview.getSettings().setJavaScriptEnabled(true);

Like this:

myWebView.loadUrl("javascript:$.mobile.showPageLoadingMsg()");

provided you have

WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM