title: WebView code generating Uncaught TypeError and Uncaught ReferenceError errors on Android 4.4.2 (API 19) emulator
body: <p>I'm having a problem with my code when running on a Android 4.4.2 KitKat (API 19) emulator...</p>
  
  <p>When I emulate my project on a Android 4.3 (API 18) emulator, it works normally and creates the mathematical expressions with MathJax:</p>
  
  <p><a href="http://imgur.com/sr3Wnz2" rel="nofollow">Image of emulator</a></p>
  
  <p>But when I use a Android 4.4.2 emulator, the app don't work correctly:</p>
  
  <p><a href="http://imgur.com/U8YW02a" rel="nofollow">Image of emulator</a></p>
  
  <p>Here is the code of my project:</p>
  
  <pre><code>package com.testes.testesapp;
  
  import android.app.Activity;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.view.View;
  import android.webkit.WebView;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends Activity implements View.OnClickListener {
  
      private int exampleIndex = 0;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          WebView webView = (WebView) findViewById(R.id.webview);
          webView.getSettings().setJavaScriptEnabled(true);
          //webView.getSettings().setBuiltInZoomControls(true);
          webView.loadDataWithBaseURL("http://test", "&lt;script type='text/x-mathjax-config'&gt;"
                                + "MathJax.Hub.Config({ " 
                                + "showMathMenu: false, "
                                + "jax: ['input/TeX','output/HTML-CSS'], " // output/SVG
                                + "extensions: ['tex2jax.js','toMathML.js'], " 
                                + "TeX: { extensions: ['AMSmath.js','AMSsymbols.js',"
                                + "'noErrors.js','noUndefined.js'] }, "
                                // + "'SVG' : { blacker: 30, "
                                // + "styles: { path: { 'shape-rendering': 'crispEdges' } } } "
                                + "});&lt;/script&gt;"
                                + "&lt;script type='text/javascript' "
                                + "src='file:///android_asset/MathJax/MathJax.js'"
                                + "&gt;&lt;/script&gt;"
                                + "&lt;span id='math'&gt;&lt;/span&gt;","text/html","utf-8","");
          EditText edit = (EditText) findViewById(R.id.edit);
          edit.setBackgroundColor(Color.LTGRAY);
          edit.setTextColor(Color.BLACK);
          edit.setText("");
          Button btnShow = (Button) findViewById(R.id.btnShow);
          btnShow.setOnClickListener(this);
          Button btnClear = (Button) findViewById(R.id.btnClear);
          btnClear.setOnClickListener(this);
          Button btnExample = (Button) findViewById(R.id.btnExample);
          btnExample.setOnClickListener(this);
      }
  
      private String doubleEscapeTeX(String s) {
          String t="";
          for (int i=0; i &lt; s.length(); i++) {
              if (s.charAt(i) == '\'') t += '\\';
              if (s.charAt(i) != '\n') t += s.charAt(i);
              if (s.charAt(i) == '\\') t += "\\";
          }
          return t;
      }
  
      private String getExample(int index) {
          return getResources().getStringArray(R.array.tex_examples)[index];
      }
  
      public void onClick(View v) {
          if (v == findViewById(R.id.btnShow)) {
              WebView webView = (WebView) findViewById(R.id.webview);
              EditText edit = (EditText) findViewById(R.id.edit);
              webView.loadUrl("javascript:document.getElementById('math').innerHTML='\\\\["
                              + doubleEscapeTeX(edit.getText().toString()) + "\\\\]';");
              webView.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
          }
          else if (v == findViewById(R.id.btnClear)) {
              WebView webView = (WebView) findViewById(R.id.webview);
              EditText edit = (EditText) findViewById(R.id.edit);
              edit.setText("");
              webView.loadUrl("javascript:document.getElementById('math').innerHTML='';");
          }
          else if (v == findViewById(R.id.btnExample)) {
              WebView webView = (WebView) findViewById(R.id.webview);
              EditText edit = (EditText) findViewById(R.id.edit);
              edit.setText(getExample(exampleIndex++));
              if (exampleIndex &gt; getResources().getStringArray(R.array.tex_examples).length - 1) 
                  exampleIndex=0;
              webView.loadUrl("javascript:document.getElementById('math').innerHTML='\\\\["
                              + doubleEscapeTeX(edit.getText().toString()) + "\\\\]';");
              webView.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
          }
      }
  
  }
  </code></pre>
  
  <p>When I press the "Example" or the "Show" button, LogCat emits the errors:</p>
  
  <pre><code>I/chromium(1254): [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot set property 'innerHTML' of null", source: http://test/ (1)
  I/chromium(1254): [INFO:CONSOLE(1)] "Uncaught ReferenceError: MathJax is not defined", source: http://test/ (1)
  </code></pre>
  
  <p>I have no idea how to fix this problem, and would like somebody's help to solve this. Thanks.</p>