I wrote the following script to change "<br>" in page text (&lt;br&gt; in HTML) into "<br/>" in HTML (a line break in page text). It will eventually do the same to "<br/>" in page text (&lt;br/&gt; in HTML), but for testing purposes I started with just "<br>". The script works perfectly in Firefox and Chrome, but does nothing in IE (not even returning an error in a try-catch clause). Any ideas why it does this or how to fix it?

var theTDs = document.getElementsByTagName("TD");
var counter1 = 0;
while(counter1 < theTDs.length)
{
var TDHTML = theTDs[counter1].HTMLContent || theTDs[counter1].innerHTML;

if(TDHTML.indexOf("<script") > -1)
{
TDHTML = "";
}
if(TDHTML.indexOf("<td") > -1)
{
TDHTML = "";
}
innerTDs = theTDs[counter1].getElementsByTagName("TD");
if(innerTDs.length > 0)
{
TDHTML = "";
}
while(TDHTML.indexOf("&lt;br&gt;") > -1)
{
var brindex = TDHTML.indexOf("&lt;br&gt;");
var substring1 = TDHTML.substring(0, brindex);
var substring2 = TDHTML.substring(brindex + 10);
var fullstring = substring1 + "<br/>" + substring2;
theTDs[counter1].innerHTML = fullstring;
TDHTML = theTDs[counter1].HTMLContent || theTDs[counter1].innerHTML;
}
counter1 += 1;
}