Posted by: tjcoppet | January 26, 2008

Safari 3 Behavior With innerHTML

Strange problem I ran into.

var child = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
child.innerHTML = "Hello <br/>World!";
parent.appendChild(child);

Inside the new div and only on Safari 3, I get: Hello World!

But flip the order:

var child = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
parent.appendChild(child);
child.innerHTML = "Hello&ltbr/>World!";

and I get: Hello
World!

This was driving me nuts.


Leave a comment

Categories