js获取html图片src,以及交互
这里是js,主要目的实现对url的获取
staticNSString * const jsGetImages =
@"function getImages(){\
var objs = document.getElementsByTagName(\"img\");
\
var imgScr = '';
\
for(var i=0;
i
imgScr = imgScr + objs[i].src + '+';
\
【js获取html图片src,以及交互】};
\
return imgScr;
\
};
";
[webView stringByEvaluatingJavaScriptFromString:jsGetImages];
//注入js方法
NSString *urlResurlt = [webView stringByEvaluatingJavaScriptFromString:@"getImages()"];
NSArray *Imgarr = [urlResurlt componentsSeparatedByString:@"+"];