Ok, so i finally ran into troubles with the innerHTML property in FireFox, heard that it has some issues, never really saw any tho until today.
Problem: when using innerHTML as such
jscript
object.innerHTML += "<div id=\"somethingNew\"></div>";
var somethingNew = document.getElementById("somethingNew");
object.innerHTML += "more new stuff";
The somethingNew variable no longer references the somethingNew div tag in the new HTML. This seems odd at first, but maybe when you think about it. When you "add" stuff to innerHTML, you are not really adding anything, you are changing the property and concatenating the old HTML to the new one. By doing this you are forcing the page to be rendered again, but the variable you used points to the old element, which might be the same, but you didn't update it. This thing gave me quite a headache today to be honest.
The solution: for IE don't use innerHTML! It has something which seems to work alot better:
insertAdjacentHTML(position, html). This
little piece seems to do magic, and not a lot of people know about it for some reason. There one proof that IE can be better than FF lol (don't kill me with its drawbacks IE has i know i've been there almost killed myself then). Now for firefox, fix well, you can do it the dirty way and update the variables after you finished changing the HTML. You can do this just by using this workaround i just found, which i must say looks promising. But this article is pretty old, so there must be something better by now.
Is it better using DOM elements for non-IE browsers to create new HTML? or more specific DIV tags? Is there a better workaround out there?
This post has been edited by Mike007: 12 Jun, 2008 - 12:20 AM