Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView causing Uncaught TypeError when loading www.google.com

I'm using WebView to load and render a variety of websites with no problem. Oddly, the one that seems to cause errors is www.google.com

When loading this page, the Search button does not work when clicked. When it is clicked, I see this error in LogCat (I also see 3 similar errors reported during the page load):

02-07 23:23:59.230: ERROR/Web Console(3721): Uncaught TypeError: Cannot call method 'getItem' of null at http://www.google.com/:342

I am enabling JavaScript (among other things) in my onResume override:

    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    settings.setDatabaseEnabled(true);

Any idea what could be causing these errors? Thanks!

like image 295
jpeskin Avatar asked Feb 08 '11 07:02

jpeskin


People also ask

What can I use instead of WebView?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

How do I enable JavaScript on WebView?

Enable JavaScript JavaScript is disabled in a WebView by default. You can enable it through the WebSettings attached to your WebView . You can retrieve WebSettings with getSettings() , then enable JavaScript with setJavaScriptEnabled() . WebView myWebView = (WebView) findViewById(R.

Is Android WebView deprecated?

Beginning October 5, 2021, Facebook Login will no longer support using Android embedded browsers (WebViews) for logging in users.

What is a WebView URL?

WebView is a view that displays web pages inside the application. It is used to turn the application into a web application.


1 Answers

I found the critical call:

settings.setDomStorageEnabled(true);

This seems to allow the browser to store a DOM model of the page elements, so that Javascript can perform operations on it.

like image 179
jpeskin Avatar answered Sep 18 '22 18:09

jpeskin