edislasm
11-15-2008, 07:45 PM
Hi everyone. I need to specify the innerHTML of an element but I've been having strange problems using innerHTML as well as Prototype's .update() function. Let's say I have this code:
alert(defaultcontent); //show the string of defaultcontent variable.
someelement.update(defaultcontent); //applies it to the element
alert(someelement.innerHTML); //shows the resulting content of the element
I've tried with several defaultcontent strings. With all of them the msg boxes show the same string as expected. This does well with both methods innerHTML and Prototype's update function. And it works in both IE and FF.
But I have a special string that brings me problems:
defaultcontent = '<TR><TH>City</TH><TH>State</TH></TR>';
I always get the first alert box with the string. But the second time it comes changed. Meaning that something happened when applying the HTML string to the element. The results I'm getting are:
in FF using innerHTML:
'CityState'
in FF using Prototype's update:
'CityState'
in IE using innerHTML:
'City</TH><TH>State</TH></TR>'
+Unknown runtime error.
in IE using Prototype's update:
Error. Object does not support this property or method.
IE with innerHTML is getting closer to the expected result, but the runtime error is something unbearable. But it sounds strange to me that in FF, both methods remove all HTML tags.
What could be wrong??
alert(defaultcontent); //show the string of defaultcontent variable.
someelement.update(defaultcontent); //applies it to the element
alert(someelement.innerHTML); //shows the resulting content of the element
I've tried with several defaultcontent strings. With all of them the msg boxes show the same string as expected. This does well with both methods innerHTML and Prototype's update function. And it works in both IE and FF.
But I have a special string that brings me problems:
defaultcontent = '<TR><TH>City</TH><TH>State</TH></TR>';
I always get the first alert box with the string. But the second time it comes changed. Meaning that something happened when applying the HTML string to the element. The results I'm getting are:
in FF using innerHTML:
'CityState'
in FF using Prototype's update:
'CityState'
in IE using innerHTML:
'City</TH><TH>State</TH></TR>'
+Unknown runtime error.
in IE using Prototype's update:
Error. Object does not support this property or method.
IE with innerHTML is getting closer to the expected result, but the runtime error is something unbearable. But it sounds strange to me that in FF, both methods remove all HTML tags.
What could be wrong??