- (void)webViewDidFinishLoad:(UIWebView*)webView;//中添加
NSString*js=@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function ResizeImages() { "
"var myimg,oldwidth;"
"var maxwidth = %f;"
"for(i=0;i
"myimg = document.images[i];"
"if(myimg.width > maxwidth){"
"oldwidth = myimg.width;"
"myimg.width = %f;"
"}"
"}"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);";
js=[NSStringstringWithFormat:js,[UIScreenmainScreen].bounds.size.width,[UIScreenmainScreen].bounds.size.width-15];
[webViewstringByEvaluatingJavaScriptFromString:js];
[webViewstringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
//设置字体大小
NSString*str =@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '90%'";
[webViewstringByEvaluatingJavaScriptFromString:str];
网友评论