Hi

I think Im dealing with an IE insertBefore bug, the script runs fine in Chrome,

I have created my own modal box which gets inserted as a new node - the first inside the <body>... however, in IE, the new box is inserted within the first <div> inside my body, which is my wrapper (centers content)... can anyone advise on where Im goign wrong, or how to correct it?

function showEmail(){
        //create new node to insert
	var blackOut = document.createElement('div');
	blackOut.className = 'blackout';
	
	//find the body tag
	var bodybox = document.getElementsByTagName('body')[0];
        //find all divs within the body
	var allDivs = bodybox.getElementsByTagName('div');
	var oldFirst = allDivs.item(0);
        
        //fill the new node with a temporary loading animation
	blackOut.innerHTML = '<div class="load"><img src="img/load.gif" /></div>';
	
        //insert new node just inside the <body> - first element
	bodybox.insertBefore(blackOut,oldFirst);
	
	/*... then make an ajax call and fill new node with contact form information... */

}

i apologise, turns out it was a CSS error that made it look like the new node was being inserted into the wrapper <div>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.