[android-developers] Re: Call a WebView javascript function from the activity?

2011-04-01 Thread Maps.Huge.Info (Maps API Guru)
You have most of it. Just add a call to the JavaScript function from
your code like this:

mWebView.loadUrl(javascript:bookBtn();) ;

That will fire the function just like if you did it in the address bar
of a browser.

Mark Murphy has this method documented in one of his books (http://
commonsware.com/). You might shell out for a subscription. Well worth
it.

-John Coryat

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Call a WebView javascript function from the activity?

2011-04-01 Thread Streets Of Boston
First, have you tried javascript:loadTOC*()* instead of javascript:loadTOC. 
You forgot the open and close braces.
 
Secondly, i'm not sure what your script does.
You want to execute an anonymous function when your document finished 
loading. This anonymous function just declares another function called *
loadTOC*, which is never called. I'm getting a little rusty in JavaScript, 
but the scope of loadTOC does not seem to be global (it is local to that 
anonymous function). 
Try to make this loadTOC function global by moving the 'function loadTOC() { 
... }' outside of the anonymous function (and be sure to not forget the open 
and close braces in your Activity when calling loadTOC).
 

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Call a WebView javascript function from the activity?

2011-04-01 Thread Maps.Huge.Info (Maps API Guru)
If you're having trouble debugging the JavaScript and HTML portion of
your webview, you can always load that portion in a browser and use
the standard debugging tools it provides to reveal errors. The
debugging capabilities of webview are pretty limited. Do check your
logs for JavaScript errors though, some show there, although they are
more cryptic than we are used to seeing in the browser console.

-John Coryat

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Call a WebView javascript function from the activity?

2011-04-01 Thread camelCaser
Thnx!!

That was too easy.  I added the brackets then moved the function to the 
body and now it sees (fires) the function.

Thanx for the help!!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en