webview.shouldOverrideUrlLoading不會接收window.location.href重定向
阿新 • • 發佈:2019-02-14
s
對於window.location.href重定向,客戶端無法獲取點選事件,所以不會主動加上url後面的引數。
建議用“模擬點選事件”的方式替代所有的“window.location.href”。
我已測過的html檔案,見附件
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>xxx</title> </head> <body youdao="bind"> <a href="http://www.baidu.com" id="link1">bbbbbbbbb</> <script> //webkit 引擎不支援除 input 和 button 以外元素的點選模擬,需要通過 dispatch 方法實現 function dispatch(c, b) { try { var a = document.createEvent("Event"); a.initEvent(b, true, true); c.dispatchEvent(a) } catch (d) { alert(d) } } dispatch(document.getElementById("link1"), "click"); document.getElementById('link1').click(); </script> </body></html>
s