Jump to content

[SOLVED] setting text using innerHTML not working in Internet Explorer


s0c0

Recommended Posts

I'm sure this has been asked before, but I'm asking again.  What is the work around for this apparent bug?  I have this snippet of code that works fine in FireFox, but throws an error in IE.

 

/*					try
				{
					var txtDocument = XMLHttpRequestObject.responseText;
					var totalsArr = txtDocument.split('-');
					document.posfrm.total.value = totalsArr[0];
					document.getElementById("total").innerHTML = totalsArr[0];
					subTotalFrm.value = totalsArr[1];
					taxFrm.value = totalsArr[2];
					taxDiv.innerHTML = totalsArr[2];
					shippingFrm.value = totalsArr[3];
					shippingDiv.innerHTML = totalsArr[3];
					infoDiv.innerHTML = totalsArr[4];
					setShippingValues(totalsArr[4]);

				}
				catch(err)
				{
					alert("error getting order total amount");
				}

 

 

I've read several blogs, and even this KB (http://support.microsoft.com/kb/276228), but I can't seem to get any of the work arounds for this to work.  Is there any easy work-around, please say yes, because I really don't want to "fix" over 1000 lines of JavaScript.

 

P.s. Your boss tells you not to worry about IE compatibility, once you complete the project he comes back and says we need it to be IE compatible....go figure, thanks!

 

Wow no replies on this.  I figured out a solution on my own.  My problem was I was setting up ID names on TD tags which for some reason causes IE to error out.  I got rid of those, and replaced them with span ID names, this resolved the problem.

 

For instance if you have the following code:

 

<script type="text/javascript">
var str = "hello world";
document.getElementById("text").innerHTML = str
<script>

 

And the following HTML:

 

<table>
<td id="text"></td>
</table>

 

This will not work, you must instead use <span id="text">, <div id="text">, or something like that to remain IE compatible.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.