星五博客

xcode中UIWebView访问JavaScript元素及对象

//访问页面标题
[webView
 stringByEvaluatingJavaScriptFromString:@"document.title"];
//访问对象、字典  var dataForWeixin={...
[webView
 stringByEvaluatingJavaScriptFromString:@"dataForWeixin.title"];
//访问自定义元素 <meta name="description" content="元素"/>
[webView
 stringByEvaluatingJavaScriptFromString:
	@"document.getElementsByName('description')[0].content"];


IOS