calling javascript from eclipse for PhoneGap

十年热恋 提交于 2019-12-22 10:14:29

问题


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:


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



来源:https://stackoverflow.com/questions/7947559/calling-javascript-from-eclipse-for-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!