2016-11-04 86 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)。此外,我嘗試了您的代碼,但仍然沒有任何反應,點擊網站上的「下一步」按鈕。 –

相關問題