JavaScript的有时不能在Android的WebView中工作 [英] JavaScript sometimes doesn't work in android's webview

查看:144
本文介绍了JavaScript的有时不能在Android的WebView中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把网页视图在我的应用程序来访问网页,其中包括一些JavaScript功能,我的目的是当用户点击网页中的链接,就会启动应用程序的新活动。我已经写了webSettings.setJavaScriptEnabled(真);在我的源$ C ​​$ CS。

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?

推荐答案

v.setWebChromeClient(新WebChromeClient()

v.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);
            }

        });

所以至少检查此code你会得到错误信息,并一件事是,Android不支持所有的JavaScript函数。

check this code so at least you will get error message and one more thing is that android doesn't supports all JavaScript functions.

这篇关于JavaScript的有时不能在Android的WebView中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆