Android Question use WebView cannot be opened

mywmshow

Member
I have a web site(https://h5.zxx.edu.cn/syncClassroom/tchMaterial), use WebView cannot be opened, but mobile browser can normal open, could you tell me what to do, thank you very much!
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Dim web1 As WebView
    web1.Initialize("")
    Activity.AddView(web1,0,0,100%x,100%y)
    web1.LoadUrl("https://h5.zxx.edu.cn/syncClassroom/tchMaterial")
End Sub
 

drgottjr

Expert
Licensed User
Longtime User
webview cannot recover from issues occurring in some of the many, many javascript files used at this site:

Uncaught TypeError: Cannot read properties of null (reading 'getItem') in https://h5.zxx.edu.cn/syncClassroom/tchMaterial (Line: 16)
Uncaught TypeError: Cannot read properties of null (reading 'getItem') in https://h5.zxx.edu.cn/js/app-f0e797ab.js (Line: 1)
Uncaught TypeError: Cannot set properties of null (setting 'value') in https://h5.zxx.edu.cn/syncClassroom/tchMaterial (Line: 1)

in looking at https://h5.zxx.edu.cn/js/app-f0e797ab.js, there are a number of references to localStorage in connection with the "getItem()" method that throws the errors mentioned above. localStorage is supported in chrome browser, but you have to turn this capability on in webview (settings.setDomStorageEnabled(true);). the default setting is false. you might need to look into using the ultimatewebview library to achieve that. technically, if you have a access to webview settings, you could enable dom storage with a line of inline java, but you're probably better off with a library that's set up to handle that unless you know what you're doing.

i base my comments above on looking for "getItem()" in https://h5.zxx.edu.cn/js/app-f0e797ab.js it appears to me that localStorage is not supported (in webview, by default).

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
EDIT:
so i turned on localstorage in webview and loaded your url. now there is a different set of errors BUT the page loads. see 2 images below.
if you add my code to your app, you should be able to load the url. given the number of errors from the site, there is no guarantee you will not encounter more problems as you navegate within the site. webview is not happy. you really shouldn't be using it as a full browser.
 

Attachments

  • mywmshow.png
    mywmshow.png
    31.2 KB · Views: 141
  • mywmshow2.png
    mywmshow2.png
    43.3 KB · Views: 146
Last edited:
Upvote 0
Top