Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling javascript from eclipse for PhoneGap

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?

like image 958
Andrew Camilleri 'Kukks' Avatar asked Mar 22 '26 14:03

Andrew Camilleri 'Kukks'


1 Answers

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

like image 54
wade montague Avatar answered Mar 24 '26 05:03

wade montague



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!