I got this code from somewhere, but I have no idea where. I will be using it to write the results of a javascript calculation that has three lines and using a table to position them. The only way I can get it to write the three lines is by duplicating the code three times within the target cells but with diffrent id's and function names. Is there a more elegant / code efficient way of doing it. BTW I have no idea how this works!!
PHP Code:
<td width="100%" align="center">
<div id="dcontent" style="width:100%;height:25px"></div>
<ilayer id="ns4dcontent" width=100% height=25px><layer id="ns4dcontent2" width=100% height=25px></layer></ilayer>
<script>
function altercontent(myStr){
//if IE 4+
if (document.all)
dcontent.innerHTML=myStr;
//else if NS 4
else if (document.layers){
document.ns4dcontent.document.ns4dcontent2.document.write(myStr);
document.ns4dcontent.document.ns4dcontent2.document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("dcontent");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(myStr);
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}}
</script>
</td>
Comment