I am trying to load a website using Phonegap on Android with the following code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setBooleanProperty("loadInWebView", true);
super.loadUrl("http://arriva.com.mt");
}
How would I execute a local javascript file on the webview?
I was having problems with this but managed to resolve it myself in the end. In your Activity you have
super.loadUrl("javascript:yourFunction()");
within your code -- make sure you have a window scoped function to fire window.yourFunction = function()
. As you're using PhoneGap I would assume that javascript is already enabled in the webview. If not, you will need to enable that too, you might find my post useful for finding out about that.
Calling javascript functions in a webview from activity class
HTH