码迷,mamicode.com
首页 > 移动开发 > 详细

iOS webview注入JS

时间:2016-03-14 12:05:44      阅读:543      评论:0      收藏:0      [点我收藏+]

标签:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
  NSString *js = @"function imgAutoFit() {      var imgs = document.getElementsByTagName(‘img‘);      for (var i = 0; i < imgs.length; ++i) {        var img = imgs[i];           img.style.maxWidth = %f;        }   }";
  js = [NSString stringWithFormat:js, [UIScreen mainScreen].bounds.size.width - 20];
 
  [webView stringByEvaluatingJavaScriptFromString:js];
  [webView stringByEvaluatingJavaScriptFromString:@"imgAutoFit()"];
}

目前没用到,备份一下

原帖地址:http://ios.jobbole.com/84216/

iOS webview注入JS

标签:

原文地址:http://www.cnblogs.com/punkrocker/p/5275045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!