I am trying to use document.getElementById (). innerHTML in JavaScript to modify information on a web page. In FireFox, this works as described in the W3C documentation, however the same method returns an "Unknown Error" in IE. JavaScript looks like this:
function Change_Info (ID, ROW, VALUE) { if (document.getElementById) { var ntext = "<td width=4\% bgcolor=#FFFFFF> </td><td width=92\% bgcolor=#FFFFFF colspan=2><font face=Arial size=2 color=#5578C4>" + VALUE + "</font></td><td width=4\% bgcolor=#FFFFFF><center> </center></td>"; document.getElementById( ID + "-" + ROW).innerHTML = ntext; return false; } }
The script is called by the MouseOver event as follows:
onmouseover='Change_Info("thetag","1","Some Info");
The script will combine the identifier with - and then ROW, which in this example will be, thetag-1. The exact tag exists in the html document. Using getElementById with a hard tag name detects the same error, and the variable method is preferred in this situation.
On the question of why the full html table information is in ntext, for some reason the nested identifiers do not work in both FireFox and IE, although the W3C specification states that it should work (obviously, both browsers did not fully enter the specifications W3C as persceribed) If someone knows about a way to access and change nested identifiers that works in both FireFox and IE, I would definitely like to know.
Also, while I only get this "Unknown error" in IE when using innerHTML to change the information. Reading works without errors.
Can anyone please indicate where my error is in the script so that I can swap text "messages" for mouseover events.
source share