全部評論(2條)
-
- ↘*社會又如何 2016-08-15 00:00:00
- 提供一個思路: 在url加上一個flag,web根據(jù)這個flag來hide不想顯示的部分,加載完成后,可以在webView中寫js-java代碼來控制web內(nèi)容的顯示隱藏。
-
贊(19)
回復(0)
-
- 梯h化s泡y軝 2017-11-22 00:00:00
- JS代碼: //根據(jù)class名稱獲取div數(shù)組 function getClass(parent,sClass) { var aEle=parent.getElementsByTagName('div'); var aResult=[]; var i=0; for(i<0;i<aEle.length;i++) { if(aEle[i].className==sClass) { aResult.push(aEle[i]); } }; return aResult; } function hideOther() { getClass(document,'nav-sides')[0].style.display='none'; getClass(document,'side-bar')[0].style.display='none'; getClass(document,'area-main')[0].style.display='none'; getClass(document,'home-foot')[0].style.display='none'; getClass(document,'enter')[0].style.display='none'; getClass(document,'crumb')[0].style.display='none'; getClass(document,'date-tab clearfix')[0].style.display='none'; document.getElementById('id_sidebar').style.display='none'; document.getElementById('top_nav').style.display='none'; document.getElementById('fix-personal').style.display='none'; document.getElementById('waterlogo').style.display='none'; getClass(document,'wrap')[0].style.minWidth=0; getClass(document,'game')[0].style.paddingTop=0; } 然后在WebViewClient的onPageFinished判斷url,加載我們的js代碼。 然后你的設置webview即可。 @Override public void onPageFinished(WebView view, String url) { if(url!=null && url.contains("/p/resource/weapon/iProductID/39")){ String fun="javascript:function getClass(parent,sClass) { var aEle=parent.getElementsByTagName('div'); var aResult=[]; var i=0; for(i<0;i<aEle.length;i++) { if(aEle[i].className==sClass) { aResult.push(aEle[i]); } }; return aResult; } "; view.loadUrl(fun); String fun2="javascript:function hideOther() {getClass(document,'nav-sides')[0].style.display='none'; getClass(document,'side-bar')[0].style.display='none'; getClass(document,'area-main')[0].style.display='none'; getClass(document,'home-foot')[0].style.display='none'; getClass(document,'enter')[0].style.display='none'; getClass(document,'crumb')[0].style.display='none';getClass(document,'date-tab clearfix')[0].style.display='none'; document.getElementById('id_sidebar').style.display='none'; document.getElementById('top_nav').style.display='none'; document.getElementById('fix-personal').style.display='none'; document.getElementById('waterlogo').style.display='none';getClass(document,'wrap')[0].style.minWidth=0;getClass(document,'game')[0].style.paddingTop=0;}"; view.loadUrl(fun2); view.loadUrl("javascript:hideOther();"); } super.onPageFinished(view, url); }
-
贊(20)
回復(0)
熱門問答
- android中的webview加載網(wǎng)頁只想顯示部分內(nèi)容改怎么做
2018-12-02 02:40:54
351
0
- android中的webview加載網(wǎng)頁只想顯示部分內(nèi)容改怎么做
2016-08-14 08:43:20
563
2
- android中的webview加載網(wǎng)頁只想顯示部分內(nèi)容改怎么做
2017-10-30 06:55:38
380
2
- Android WebView 加載網(wǎng)頁 樣式錯誤
- 使用AndroidwebVIew加載網(wǎng)頁出現(xiàn)錯位情況但是使用UC瀏覽器打開相同網(wǎng)頁卻沒有這樣的問題請問WebView應該如何設置才能不出現(xiàn)這種樣式錯誤的問題... 使用 Android webVIew 加載網(wǎng)頁 出現(xiàn)錯位情況 但是使用UC瀏覽器打開相同網(wǎng)頁卻沒有這樣的問題 請問WebView應該如何設置 才能不出現(xiàn)這種樣式錯誤的問題 展開
2015-09-01 01:10:50
390
2
- android中webview加載網(wǎng)頁,為什么有的網(wǎng)站會被加載兩次
2016-01-04 11:06:10
451
1
- android中webview加載網(wǎng)頁,為什么有的網(wǎng)站會被加載兩次
2016-08-18 02:37:32
423
2
- android webview 加載網(wǎng)頁后自動返回為什么
2018-11-22 07:08:53
391
0
- 怎樣解決替換android中webview加載網(wǎng)頁失敗時的頁面
2015-10-23 03:16:05
311
1
- android webview 加載網(wǎng)頁。當修改樣式之后,無法更新
- 我使用webview訪問網(wǎng)頁。出現(xiàn)一個問題。網(wǎng)頁的樣式引用方式如下:
1、Z開始訪問很ok。2、后面需要改動這個樣式文件。但是改變了之后,... 我使用webview 訪問網(wǎng)頁。出現(xiàn)一個問題。 網(wǎng)頁的樣式引用方式如下: 1、Z開始訪問很ok。 2、后面需要改動這個樣式文件。但是改變了之后, webview 訪問 還是之前的老樣式。沒有改變。 3、必須改變 樣式的 引用路徑,讓其重新加載樣式。訪問才正常顯示 但是 這種文件多了,改起來很麻煩 這種 可以處理 android webview 這邊嗎?來解決這個問題? 展開
2017-12-10 07:11:38
729
1
- android webview載入網(wǎng)頁 網(wǎng)頁中文本框輸入的問題
- 我做了一個webview加載一個網(wǎng)頁網(wǎng)頁里面有一個百度輸入框點擊這個框會彈出軟鍵盤然后使用軟鍵盤輸入可是每點一次軟鍵盤我的webview就會滾動一下滾動到上邊然后再滾動回來求解!??!... 我做了一個webview 加載一個網(wǎng)頁 網(wǎng)頁里面有一個百度輸入框 點擊這個框 會彈出軟鍵盤 然后使用軟鍵盤輸入 可是每點一次軟鍵盤 我的webview就會滾動一下 滾動到上邊 然后再滾動回來求解?。?! 展開
2013-08-04 06:10:17
404
1
- 關于Android中WebView在加載網(wǎng)頁的時候,怎樣應用本地的CSS效果
2016-02-03 04:57:54
401
1
- 關于Android中WebView在加載網(wǎng)頁的時候,怎樣應用本地的CSS效果
2016-08-16 10:22:27
414
1
- 關于Android中WebView在加載網(wǎng)頁的時候,怎樣應用本地的CSS效果
2014-12-01 21:18:39
357
2
- android 用什么加載網(wǎng)頁
2016-12-04 21:43:20
251
1
- ios webview怎樣刪除加載網(wǎng)頁中的內(nèi)容
2017-12-06 06:29:32
332
2
- android webview 加載assets html 無法加載網(wǎng)絡圖片
- androidwebview加載assetshtml無法加載網(wǎng)絡圖片,數(shù)據(jù)是有的,都是網(wǎng)絡圖片沒有顯示,直接加載網(wǎng)絡上面的頁面是有圖片的,但是通過assets就不能加載網(wǎng)絡圖片了... android webview 加載assets html 無法加載網(wǎng)絡圖片, 數(shù)據(jù)是有的,都是網(wǎng)絡圖片沒有顯示,直接加載網(wǎng)絡上面的頁面是有圖片的, 但是通過assets 就不能加載網(wǎng)絡圖片了 展開
2015-06-25 15:02:50
498
1
- webview加載網(wǎng)頁如何讓它加載電腦格式的網(wǎng)頁,不加載手機格式
- 這么一種情況。一個網(wǎng)頁有電腦版和手機版,如何讓webview只加載的電腦版不加載手機版... 這么一種情況。一個網(wǎng)頁有電腦版和手機版,如何讓webview只加載的電腦版不加載手機版 展開
2017-06-24 00:30:40
456
1
- android怎樣在加載網(wǎng)頁的同時加載個進度條
2015-07-09 01:16:09
410
2
4月突出貢獻榜
推薦主頁
最新話題





參與評論
登錄后參與評論