Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.getElementById() returns null on IE9

I'm working on a popup and i'm having some hard time with Internet Explorer 9. This is the piece of code that gives me trouble:

var popUp= document.getElementById('projectInfo');
popUp.style.left=(tempX-310)+'px';
popUp.style.top=(tempY-110)+'px';

In IE9 (haven't tested in prior versions), popup is null. In adition, i've tried including my .js file just before the body closing tag and wrapping my function in a "document.ready()" function but none of this worked. The same code though works perfectly in Opera, Chrome and Firefox. Does anyone know what's going on?

Note: The function is called in the body's onLoad atribute of my html.

like image 655
Francisco Ragout Avatar asked Jan 24 '12 02:01

Francisco Ragout


1 Answers

Without using function it can't work

 window.onload = function() {
   var popUp= document.getElementById('projectInfo');
   popUp.style.left=(tempX-310)+'px';
   popUp.style.top=(tempY-110)+'px';
 }
like image 151
azarudeen ajees Avatar answered Oct 03 '22 22:10

azarudeen ajees