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

1 comment:

Armand said...

.innerHTML fails in IE on many occasions.

This link
http://webbugtrack.blogspot.com/2007/10/bug-124-setting-innerhtml-problem-no1.html

and this one
http://webbugtrack.blogspot.com/2007/12/bug-210-no-innerhtml-support-on-tables.html

indicate 2 of the biggest issues. maybe you have encountered another one?