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 http://slayeroffice.com/archives/?p=172. Does anybody have any other suggestions on how to handle this issue?

Thanks so much.

davidw88Asked:
Who is Participating?
 
leakim971PluritechnicianCommented:
Hello davidw88,

Work for me.
Could you post your full code ?

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

Open in new window

0
 
davidw88Author Commented:
Cool. Thanks leakim971!
0
 
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points! Have fun!
0
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.