Android WebView獲取網頁中JavaScript彈框內容
網頁中彈窗的js代碼為
<script type="text/javascript" language="javascript"> function duihuan(){ alert("請登陸!"); } </script>
根據需求要獲取 請登錄這段文字 具體實現方法如下
在WebView中
WebChromeClient webchromeclient = new WebChromeClient() { public boolean onJsAlert(WebView view, String url, String message, JsResult result) { Toast.makeText(MainActivity.this, message , Toast.LENGTH_LONG).show(); result.confirm(); return true; } };
message 即為要獲取的“請登陸!”
//////////////////////////////////////////////
原創聲明 轉載請注明
本文出自 Ray-Ray的博客
文章地址 http://www.cnblogs.com/rayray/archive/2013/06/07/3119758.html
感謝大家的推薦和收藏
你的支持! 我們的動力!