- (void)webViewDidFinishLoad:(UIWebView *)webView{
webViewDidLoad = YES;
hideManualHud(0);
[webView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function ResizeImages() { "
"var myimg,oldwidth;"
"var maxwidth=%lf;" //缩放系数
"for(i=0;i <document.images.length;i++){"
"myimg = document.images[i];"
"if(myimg.width > maxwidth){"
"oldwidth = myimg.width;"
"oldHeight = myimg.height;"
"myimg.width = maxwidth;"
"myimg.height = oldHeight * (maxwidth/oldwidth);"
"}"
"}"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);",Screen_Width - 10 ]];
//拦截网页图片 并修改图片大小
[webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
}
这个会有个小问题,在实际使用中,网络环境较差就会有一个从大压到小的过程,如果有谁有好的解决方法,可以发评论给我,谢谢大神