0

如何将 JQuery 库添加到 Android WebView 中加载的页面中?我的网页视图:

 webview.getSettings().setJavaScriptEnabled(true);
 webview.loadUrl(url);
4

1 回答 1

0

我必须从 js 代码中删除转义符(如\n)。我也不得不等到 JQuery 被加载:

load.tryReady = function(time_elapsed) {  
   // Continually polls to see if jQuery is loaded.  
   if (typeof $ == "undefined") { // if jQuery isn't loaded yet...  
       if (time_elapsed <= 5000) { // and we havn't given up trying...  
           setTimeout("load.tryReady(" + (time_elapsed + 200) + ")", 200); // set a timer to check again in 200 ms.  
       } else {  
           alert("Timed out while loading jQuery.")  
       }  
   } else {  
      // Any code to run after jQuery loads goes here!  
   }  
} 

http://www.coderanch.com/t/504284/HTML-CSS-JavaScript/dynamically-load-jQuery-javascript-library

于 2012-10-06T19:40:19.277 回答