JavaScript, innerHTML not being recognised by javascript
<p>I have the following code for my website:-</p>

<pre><code>function HCreateWindow(top,left,width,height,zindex,parent) {
var handle = Math.floor(Math.random()*10000000000);

if(parent==null) {
document.write("&lt;div id=\"HWINDOW" + handle + "\"style=\"top: " + top + "px; left: " + left + "px;width: " + width + "px;height: " + height + "px; border: 1px solid black;z-index: " +zindex +"\" class=\"drag\"&gt;&lt;/div&gt;");
} else {
    document.getElementById("HWINDOW" + parent).innerHTML += "&lt;div id=\"HWINDOW" + handle + "\"style=\"top: " + top + "px; left: " + left + "px;width: " + width + "px;height: " + height + "px; border: 1px solid black;z-index: " +zindex +"\" class=\"drag\"&gt;&lt;/div&gt;";
}
return handle;
}
</code></pre>

<p>It turns out that the innerHTML causes internet explorer 8 to say that innerHTML is null or not an object.  Thinking that this may be a bug with IE I updated to IE9.  Still have the same problem.  However, if I add the line before the 'if':-</p>

<pre><code>document.write(parent);
</code></pre>

<p>it works, as if innerHTML is recognised.  Got no idea how the two commands are related.  The only thing is that I do not want to display the contents of 'parent', as this would make the web page untidy.  Any clues?</p>
