Android WebView doesn't load jQuery

前端 未结 8 1579
抹茶落季
抹茶落季 2020-12-14 21:08

I\'m making a webapp and I\'m using jQuery.

I\'ve made a simple android application with a WebView in it, and I load my url: www.mydomain.com

In mydomain.com

8条回答
  •  半阙折子戏
    2020-12-14 21:24

    Where is your js/jquery_1.4.2_min.js script located? If it is located in your assets directory, then you should initialize the webView giving it the assets directory as baseUrl:

    webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "UTF-8", null);
    

    or

    webView.loadUrl("file:///android_asset/file.html");
    

    You could try to create a simple .js file with a simple function like

    function dummy(document) { document.write("Hooray it works"); }
    

    and try to access the dummy function in your html to test if the .js file is included.

提交回复
热议问题