#define ScreenWidth ([UIScreen mainScreen].bounds.size.width)
- (void)webViewDidFinishLoad:(UIWebView *)webView{
//等比例修改图片
NSString *str = [NSStringstringWithFormat:@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function ResizeImages() { "
"var myimg,oldwidth;"
"var maxwidth = %f;" // UIWebView中显示的图片宽度
"for(i=0;i <document.images.length;i++){"
"myimg = document.images[i];"
"if(myimg.width > maxwidth){"
"oldwidth = myimg.width;"
"myimg.width = maxwidth;"
"}"
"}"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);",ScreenWidth-10];
[webView stringByEvaluatingJavaScriptFromString:str];
[webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
NSString *webHeight = [webViewstringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"];
NSLog(@"网页高度:%@",webHeight);
}