admin管理员组文章数量:1331091
I put a webview in my application to visit a webpage which includes some javascript functions, my purpose is when users click a link in the webpage, it will start a new activity in the application. I've written "webSettings.setJavaScriptEnabled(true);" in my source codes.
It works well in most of the time, however sometimes it doesn't work, there is no response when users click, and I don't know why because the environment is not changed at all. Has anybody know why?
I put a webview in my application to visit a webpage which includes some javascript functions, my purpose is when users click a link in the webpage, it will start a new activity in the application. I've written "webSettings.setJavaScriptEnabled(true);" in my source codes.
It works well in most of the time, however sometimes it doesn't work, there is no response when users click, and I don't know why because the environment is not changed at all. Has anybody know why?
Share asked Jul 22, 2010 at 7:04 GarfexGarfex 1111 silver badge4 bronze badges3 Answers
Reset to default 3v.setWebChromeClient(new WebChromeClient() {
@Override
public void onConsoleMessage(String message, int lineNumber,String sourceID) {
Log.d("MyApplication", message + " -- From line "+ lineNumber + " of " + sourceID);
super.onConsoleMessage(message, lineNumber, sourceID);
}
});
check this code so at least you will get error message and one more thing is that android doesn't supports all JavaScript functions.
I had the same issue. I changed the event for from 'click' to 'touchstart' and now its awesome.
Credit is due to Imran Omar Buksh for this idea.
... other HTML ...
</body>
<script type="text/javascript">
document.querySelector("#checkItOut").addEventListener("touchstart",
function() {
jsObject.performClick();
});
</script>
</html>
本文标签: JavaScript sometimes doesn39t work in android39s webviewStack Overflow
版权声明:本文标题:JavaScript sometimes doesn't work in android's webview - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742265678a2443345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论