Replacing inner HTML fails despite onload function
<p>I rarely have to do any Javascript and I seem to fail doing the easiest tasks. I am trying to replace a string in two divs. The first div gets replaced, the second one is not found with the error message:</p>

<p>drawings.html:20 Uncaught TypeError: Cannot set property 'innerHTML' of     null</p>

<p>However I tried the usual remedies of putting my code in an 'onload' function and putting the script at the end of the body tag. What else could possibly go wrong?</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div id="cell1"&gt;test&lt;div&gt;
&lt;div id="cell2"&gt;test&lt;div&gt;

&lt;script&gt;

window.onload = function() {
  replace();
}

function replace() {
  console.log("replace");
  document.getElementById("cell1").innerHTML = "cell1";
  document.getElementById("cell2").innerHTML = "cell2";
}

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>