i have tried a few tutorials but i cant get this working. I am trying to create a div with the id of overlay and insert it right after the body tag when a function is run. can anyone help? thanks

Here's a simple demo, to get you started!

<html>
<head>
<title><!--Sample--></title>
<script language="JavaScript"type="text/javascript">
<!--
function createDiv() 
{ var _body = document.getElementsByTagName('body') [0];
var _div = document.createElement('div');
var _text = document.createTextNode('Creating Div Element')
_div.appendChild(_text);
_body.appendChild(_div);
}
window.onload = createDiv;
-->
</script>
</head>
<body>
</body>
</html>

If you need something else just let me know. Good day to you...

thanks for the replies i ended up doing this

function createDivs() {
var div = document.createElement('div');
		var container = document.createElement('div');
    	div.id = 'overlay';
		container.id = 'form_container';
if (document.body.firstChild){
      	document.body.insertBefore(div, document.body.firstChild);
		document.body.insertBefore(container, document.body.firstChild);
		} else {
      	document.body.appendChild(div);
		document.body.appendChild(container);
		}
}
This question has already been answered. Start a new discussion instead.