http://m.haodou.com/topic-327282.html?id=327282 chrome浏览器打开

选择你要隐藏的控件


其中右下角中是这个控件对应的css代码,在其中添加一行display:none,这时这个选中的控件就被隐藏起来了.但是我们主要通过javascript去操作这个控件
用js代码区获取到要隐藏的控件
点击console -> 在命令行中输入要执行的代码 -> 返回执行结果


获取到要隐藏的元素:

获取到要隐藏的元素:

设置获取到控件的display属性


UIWebView的使用:
//创建webview
self.webview= [[UIWebViewalloc] initWithFrame:self.view.frame];
[self.viewaddSubview:_webview];
//设置代理
self.webview.delegate=self;
//发送请求
[_webview loadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://m.haodou.com/topic-327282.html?id=327282"]]];

#pragmamark-UIWebViewDelegate
-(void)webViewDidFinishLoad:(UIWebView *)webView{
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('adpic')[0].style.display = 'none'"];
}
这个回调函数会在webview 请求网页成功会执行这个方法,当执行这个方法时,我们就用webview去执行屏蔽广告的js代码.

网友评论