19 September 2008

IE innerHTML - "Unknown runtime error"

"Unknown runtime error" -- only in IE. Occur when click 'innerHTML WITH form tag'

<html>
<body>
<form>
<div id="replaceme"></div>
</form>
<div onclick="replace();return false;">innerHTML WITHOUT form tag</div><br/>
<div onclick="replace2();return false;">innerHTML WITH form tag</div>
<script>
function replace() {
document.getElementById('replaceme').innerHTML = 'REPLACED';
}
function replace2() {
document.getElementById('replaceme').innerHTML = '<form>REPLACED form</form>';
}
</script>
</body>
</html>


innerHTML supposed to supported on all major browser, http://www.quirksmode.org/dom/innerhtml.html

Current solution, don't wrap the #replaceme div in form tag