954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ie insertBefore bug

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 ... however, in IE, the new box is inserted within the first 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... */

}
lifeworks
Junior Poster
145 posts since Nov 2007
Reputation Points: 15
Solved Threads: 2
 

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

lifeworks
Junior Poster
145 posts since Nov 2007
Reputation Points: 15
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: