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!

<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')
window.onload = createDiv;

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 {
This question has already been answered. Start a new discussion instead.