1 private void initWebView(String url) {
2 twoCode.loadUrl(url);
3 WebSettings settings = twoCode.getSettings();
4 settings.setJavaScriptEnabled(true);// 设置支持javascript脚本
5
6 twoCode.setWebViewClient(new WebViewClient() {
7 public boolean shouldOverrideUrlLoading(WebView view, String url) {
8 view.loadUrl(url);
9 return true;
10 }
11
12 @Override
13 public void onPageFinished(WebView view, String url) {
14 super.onPageFinished(view, url);
15 String fun = "javascript:function getClass(parent,mClass)" +
16 "{" +
17 "var aEle=parent.getElementsByTagName('div');" +
18 "var aResult=[];" +
19 "var i=0;" +
20 "for(i<0; i<aEle.length; i++) {" +
21 "if(aEle[i].className==mClass)" +
22 "{" +
23 "aResult.push(aEle[i]);" +
24 "}" +
25 "};" +
26 "return aResult;" +
27 "}";
28 view.loadUrl(fun);
29
30 String fun2 = "javascript:function hideOther() " +
31 "{" +
32 "getClass(document,'horizontal-padding')[0].style.display='none';" +// 摇一摇或点击二维码刷新
33 "getClass(document,'text-right horizontal-padding vertical-margin')[0].style.display='none';" +// 如何开门?获取帮助
34 "document.getElementById('header').style.display='none';" +// 锁掌柜体验群
35 "document.getElementById('footer').style.display='none';" +// Copyright ©2014-2016. uclbrt, inc. All Right Reserved.
36 "document.getElementById('roomInfo').style.display='none';" +// 测试楼栋 一层 103
37 "}";
38 view.loadUrl(fun2);
39 view.loadUrl("javascript:hideOther();");
40 }
41 });
42
43 }
js代码
1 function getClass(parent,mClass)
2 {
3 var aEle=parent.getElementsByTagName('div');
4 var aResult=[];
5 var i=0;
6 for(i<0;i<aEle.length;i++)
7 {
8 if(aEle[i].className==mClass)
9 {
10 aResult.push(aEle[i]);
11 }
12 };
13 return aResult;
14 }
15
16 function hideOther()
17 {
18 getClass(document,'horizontal-padding')[0].style.display='none';
19 getClass(document,'text-right horizontal-padding vertical-margin')[0].style.display='none';
20 getClass(document,'advertisementContainer')[0].style.display='none';
21 getClass(document,'copyright')[0].style.display='none';
22 document.getElementById('header').style.display='none';
23 document.getElementById('footer').style.display='none';
24 document.getElementById('roomInfo').style.display='none';
25 document.getElementById('actionListContainer').style.display='none';
26 getClass(document,'modal-body')[0].style.display='none';
27 getClass(document,'modal fade')[0].style.display='none';
28 }