calling javascript from eclipse for PhoneGap

2019-05-15 09:57发布

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?

1条回答
我只想做你的唯一
2楼-- · 2019-05-15 10:36

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

查看更多
登录 后发表回答