如何将JQuery(或任何)js库添加到Android WebView中加载的页面中?

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

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

我不得不从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