Update: I just narrowed my problem:
Why this does not work:
var tmp = document.createElement('tbody');
tmp.innerHTML="<tr><td>hello</td></tr>";
tmp gets the string hello. tr and td html is lost (on FireFox). Why is this? and how can i make such an html injection?
The original question:
I need to enter arbitrary HTML after an arbitrary element into arbitrary HTML documents. I came across this method (we insert the html line into the dynamically generated div, get our first element and paste it in the right place):
var tmp = document.createElement('div');
tmp.innerHTML = _injected_html;
var new_w = tmp.firstChild;
var parent = insertion_point.parentNode;
parent.insertBefore(new_w, insertion_point.nextSibling);
The problem is that this does not work when trying to enter table elements. if the html entered is, for example,
"<tr> <td> table data </td> </tr>"
_tmp.innerHTML = _injected_html; will not accept it (adding tr under the div element).
Any idea how to make this work for any tag?