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>