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:
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.
Up to now, I have found a solution that works in FF and IE. The solution is using the BetterInnerHTML function by Craig Buckler from Optimal Works.
The thing is working fine. But I don't see why I have to add more libraries if I'm using already Prototype Framework. Well, congratulations for Craig Buckler.
ths solutions might also be not to use a framework, what you are trying to do is extremely simple.with plain javascript you would have your piece of code hence "you would know what you have" with prototype or other library you have an abstraction layer of one hundreds or more lines to start your search for debugging a two line code.