WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);//支持JS
String js = "<script type=\"text/javascript\">" +
"var imgs = document.getElementsByTagName('img');" + // 找到img标签
"for(var i = 0; i<imgs.length; i++){" + // 逐个改变
"imgs[i].style.width = '100%';" + // 宽度改为100%
"imgs[i].style.height = 'auto';" +
"}" +
"</script>";
webview.loadDataWithBaseURL(null, result.getDetails() + js, "text/html", "utf-8", null);
webView加载HTML文件
最新推荐文章于 2024-06-15 11:15:55 发布