Note that there are some explanatory texts on larger screens.

plurals
  1. POdocument.getElementById().innerHTML fails with 'Unknown Error' in IE
    text
    copied!<p>I'm trying to use document.getElementById().innerHTML in a JavaScript to change information in a webpage. On FireFox this works as described in the W3C documentation, however, the same method returns 'Unknown Error' in IE. The JavaScript looks like this:</p> <pre><code>function Change_Info (ID, ROW, VALUE) { if (document.getElementById) { var ntext = "&lt;td width=4\% bgcolor=#FFFFFF&gt;&amp;nbsp;&lt;/td&gt;&lt;td width=92\% bgcolor=#FFFFFF colspan=2&gt;&lt;font face=Arial size=2 color=#5578C4&gt;" + VALUE + "&lt;/font&gt;&lt;/td&gt;&lt;td width=4\% bgcolor=#FFFFFF&gt;&lt;center&gt;&amp;nbsp&lt;/center&gt;&lt;/td&gt;"; document.getElementById( ID + "-" + ROW).innerHTML = ntext; return false; } } </code></pre> <p>The script is called by a MouseOver event like this:</p> <pre><code>onmouseover='Change_Info("thetag","1","Some Info"); </code></pre> <p>The script would combine ID with a - and then ROW, which, in this example would be, thetag-1. The exact tag does exist in the html document. Using getElementById with the hardcoded tag name, reveils the same error, and the variable method is the prefered one in this situation.</p> <p>To questions regarding why full html table information is in ntext, for whatever reason nested ID's fail on <em>both</em> FireFox and IE, even though the W3C specification states it should work (obviously both browsers have not fully implimented the W3C specs as persceribed). If someone knows of the way to access and change nested ID's, that works in both FireFox and IE, I'd sure like to know it.</p> <p>Additionally, as yet I'm only getting this 'Unknown Error' in IE when using innerHTML to <em>change</em> the information. Reading works without error.</p> <p>Can someone point out where my scripting error is so that I can swap text 'messages' on mouseover events.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload