0

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... */

}
1
Contributor
1
Reply
6
Views
7 Years
Discussion Span
Last Post by lifeworks
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.