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!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.