8

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!

jpeskin
  • 2,801
  • 4
  • 28
  • 27

2 Answers2

39

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.

jpeskin
  • 2,801
  • 4
  • 28
  • 27
0

Instead of Google.com try google.lk or google.co.in something. Google.com usually re-directs to someother url.

But ideally even if re-directs it should work.

Jay Mayu
  • 17,023
  • 32
  • 114
  • 148