have a problem with this code when working in IE
it gives me 0,0 coords when i use iframe tag but gives correct coords when using firefox
[CODE=javascript]function GetRealOffset(i d)
{
var elem = document.getEle mentById(id);
var leftOffset = elem.offsetLeft ;
var topOffset = elem.offsetTop;
var parent = elem.offsetPare nt;
while(parent != document.body)
{
leftOffset += parent.offsetLe ft;
topOffset += parent.offsetTo p;
parent = parent.offsetPa rent;
}
var Offsets = new Object();
Offsets.top = topOffset;
Offsets.left = leftOffset;
alert(Offsets.t op + " " +Offsets.left)
return Offsets;
}[/CODE]
i found out some more function and they r all giving me 0,0 coords
i read in a tutorial that IE gives 0,0 coords for all elements unless the page is loaded but i want the offset values when the page is loading coz im putting advertisements in the iframes and some pages can take minutes to load.
All these functions r working fine in mozilla tho
i think what i need it a function to get the correct offset values when the page is loading in IE
it gives me 0,0 coords when i use iframe tag but gives correct coords when using firefox
[CODE=javascript]function GetRealOffset(i d)
{
var elem = document.getEle mentById(id);
var leftOffset = elem.offsetLeft ;
var topOffset = elem.offsetTop;
var parent = elem.offsetPare nt;
while(parent != document.body)
{
leftOffset += parent.offsetLe ft;
topOffset += parent.offsetTo p;
parent = parent.offsetPa rent;
}
var Offsets = new Object();
Offsets.top = topOffset;
Offsets.left = leftOffset;
alert(Offsets.t op + " " +Offsets.left)
return Offsets;
}[/CODE]
i found out some more function and they r all giving me 0,0 coords
i read in a tutorial that IE gives 0,0 coords for all elements unless the page is loaded but i want the offset values when the page is loading coz im putting advertisements in the iframes and some pages can take minutes to load.
All these functions r working fine in mozilla tho
i think what i need it a function to get the correct offset values when the page is loading in IE
Comment