Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
60
rated 0 times [  62] [ 2]  / answers: 1 / hits: 21016  / 13 Years ago, wed, december 28, 2011, 12:00:00

I wanted to know if there is any way that I can call a JavaScript function from native Android Activity.



I came across:



webView.loadUrl(javascript:hello());


But it did not work for me.



Also, how will Android know in which html page does this JavaScript function reside?


More From » android

 Answers
10

Android can only call the javascript method if an html page is currently loaded in webView



webView.loadUrl(javascript:hello());


will call hello method writen in the html page only if the page containing this method is currently loaded in the webview control



first call



webview.loadUrl(Your html page url);


then call



webView.loadUrl(javascript:hello());

[#88344] Monday, December 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mira

Total Points: 460
Total Questions: 108
Total Answers: 99

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
mira questions
;