2016-11-04 87 views
0

我遇到了一个非常不寻常的可能是noobish的问题。 Wordpress上有这个网站,我必须在webview中显示。它会对名称和电子邮件的输入进行一些检查,然后Next按钮显示其余内容(最有可能是JS,但确实实现 - 在web编程中目前太糟糕了)。它在移动浏览器上的工作也很好。Android WebView无法加载(可能)Javascript虽然浏览器确实

问题是,webview似乎没有执行任何操作点击Next按钮。我搜索了一些SO问题,并用webview设置做了许多试验和错误,但无济于事。

启用Javascript的web视图,顺便说一句。这里是网址的链接,如果有人想知道(也可以告诉我)究竟是什么问题:http://www.stressandanxietymanagement.com/stress-test/

也许我错过了一些非常基本的东西。顺便说一句,请不要在答复中发布网址。解决此问题后,我可能不得不删除链接。

编辑:logcats也显示一些相关的

11-05 03:50:56.319 19071-19071/innovation.stressmanagement I/chromium: [INFO:CONSOLE(2)] "JQMIGRATE: Migrate is installed, version 1.4.1", source: http://www.stressandanxietymanagement.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 (2) 
11-05 03:52:00.619 19071-19071/innovation.stressmanagement I/chromium: [INFO:CONSOLE(54)] "Uncaught TypeError: Cannot read property 'getItem' of null", source: http://www.stressandanxietymanagement.com/wp-content/plugins/quiz-master-next/js/qmn_quiz.js?ver=4.6.1 (54) 
11-05 03:52:11.849 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:12.396 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:16.612 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:21.136 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:23.873 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:26.920 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:27.983 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:27.988 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:29.597 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:30.528 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:32.503 19071-22147/innovation.stressmanagement W/chromium: [WARNING:keycode_converter.cc(91)] empty code string 
11-05 03:52:46.558 19071-19071/innovation.stressmanagement I/chromium: [INFO:CONSOLE(54)] "Uncaught TypeError: Cannot read property 'getItem' of null", source: http://www.stressandanxietymanagement.com/wp-content/plugins/quiz-master-next/js/qmn_quiz.js?ver=4.6.1 (54) 

Uncaught TypeError显示在点击Next按钮。但问题是,它如何在web浏览器上正常工作,但在webView中却不能正常工作?

编辑:

我用这个Advanced WebView Library这工作得很好。所以,如果其他人仍然有类似的问题,试试这个库(或任何其他选择)。

但是,我想知道为什么WebView小部件内置工作不正常。

感谢

+0

检查logcat的日志 – petey

+0

@petey他们似乎并没有被给予任何暗示。他们大多数只是“表面”。 “LibEGL”相关但没有任何错误显示。 –

+0

一个建议是将其挂接到远程Chrome调试:https://developers.google.com/web/tools/chrome-devtools/remote-debugging/并查看该页面的功能。您也可以调试网页浏览https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews –

回答

0

,当我遇到这样的问题得到了某种可见debugg消息填充的代码,比如增加一个div到主DOM和汽车数字他们,所以我知道脚本停止在那里。

+0

请您详细说明一下。我没有得到你很多。 该网站由他人制作。此外,我刚刚熟悉基本的HTML和CSS。这样的调试可以用这么多的知识来完成吗? –

+0

由于我不能看到JavaScript日志我需要其他的反馈,我把一个div放在屏幕的可见位置,然后在javascript中清理并在安全级别中添加数字。如果你使用jQuery,你可以使用类似$(“#divId”)。empty()。append(“4”) –

+0

这是要在应用程序或网页中完成吗?对不起,我在这个域名太糟糕了,该网站已被其他一些我无法访问的人编码。我甚至不知道在WordPress主题中可能有这种事情。 –

0

使用webview应该是直截了当的。请尝试以下操作:

wv = (WebView) mRootView.findViewById(R.id.web_view); 
    wv.getSettings().setJavaScriptEnabled(true); 
    wv.setWebViewClient(new WebViewClient() { 
     public void onPageFinished(WebView view, String url) { 
      // do whatever you want here once the page is loaded 
     } 

     @SuppressWarnings("deprecation") 
     @Override 
     public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 
      // TODO: handle error in some way 
     } 

     @TargetApi(android.os.Build.VERSION_CODES.M) 
     @Override 
     public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError err) { 
      // manage however you want 
     } 
    }); 
    wv.loadUrl("http://www.stressandanxietymanagement.com/stress-test"); 
} 
+0

你有工作吗?我的代码与您的代码相同(仅使用自定义webview客户端来覆盖url)。此外,我尝试了您的代码,但仍然没有任何反应,点击网站上的“下一步”按钮。 –

相关问题