For ios, the UIWebView
component has a method called stringByEvaluatingJavaScriptFromString
which provides a bridge between the native application and the javascript inside webview. With this method you can send messages to native functions from javascript. Actually, Phonegap's native functionality is based on this function.
For Android and other platforms, i'm sure there are similar functions that allow you to do the same thing, i haven't investigated them.