title: HtmlUnit Javascript: Cannot read property "style" from null
body: <p>I have a problem using HtmlUnit.<br>
  I think the website contains some wrong javascript code which isn't a problem for the Firefox or Chrome but for HtmlUnit.</p>
  
  <p>When I execute the Java code from below it throws the exception I also mentioned down below. </p>
  
  <p>I've already tried:</p>
  
  <blockquote>
    <p>client.getOptions().setThrowExceptionOnFailingStatusCode(false);
    client.getOptions().setThrowExceptionOnScriptError(false);</p>
  </blockquote>
  
  <p>Well it worked, I didn't get an exception anymore but I couldn't execute any javascript code anymore.</p>
  
  <blockquote>
    <p>page.executeJavaScript(javaScriptCode)</p>
  </blockquote>
  
  <p>From now on every javascript request result in an useless value or didn't even made changes to the page.</p>
  
  <p>I just want to execute my Java code without getting an exception.<br>
  I hope somebody is able to help me. </p>
  
  <p><strong><em>My Java code</em></strong></p>
  
  <pre><code>    WebClient client = new WebClient();
      client.getOptions().setJavaScriptEnabled(true);
      HtmlPage page = client.getPage("xxx");
  </code></pre>
  
  <p><strong><em>Part of the javascript code from the webpage</em></strong></p>
  
  <pre><code>function checkDeptLogin() {
          if (logintextboxvalidate == "_Dept_login")
          {
              visibleaccount();
          }
  
          document.getElementById('leftcolmnmain').style.display = 'block'; //Line 168
          document.getElementById('stapleid').style.display = 'none';
  
          if (document.getElementById('postlstinfoid') != null)
          {
              document.getElementById('postlstinfoid').style.display = 'none';
          }
      }
  </code></pre>
  
  <pre><code>    document.write('&lt;div id = "leftcolmnmain" style="display:none"&gt;'); //Line 1778 
  </code></pre>
  
  <blockquote>
    <p>EcmaError: lineNumber=[168] column=[0] lineSource=[null]
    name=[TypeError] sourceName=[script in xxx/startwlm/Start_Wlm.htm from
    (23, 54) to (223, 10)] message=[TypeError: Cannot read property
    "style" from null (script in xxx/startwlm/Start_Wlm.htm from (23, 54)
    to (223, 10)#168)] com.gargoylesoftware.htmlunit.ScriptException:
    TypeError: Cannot read property "style" from null (script in
    xxx/startwlm/Start_Wlm.htm from (23, 54) to (223, 10)#168)</p>
  </blockquote>