Safari: document.createElement does not work?

Hi experts,

I am testing my web application and found that

obj = document.createElement(...)

does not work on Safari though it works fine on Firefox, IE8 and Chrome.

I googled online and found this post Does anybody have any other suggestions on how to handle this issue?

Thanks so much.

Who is Participating?
Hello davidw88,

Work for me.
Could you post your full code ?

<script type="text/javascript">
	function addElement() {
	  newDiv = document.createElement("div");
	  newDiv.innerHTML = "<h1>Congratulations!</h1>";
	  mydiv = document.getElementById("div1");
	  document.body.insertBefore(newDiv, mydiv);
<body onload="addElement()">
	<div id="div1">I'm the next line</div>

Open in new window

davidw88Author Commented:
Cool. Thanks leakim971!
You're welcome! Thanks for the points! Have fun!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.