I've got it working in IE by subtracting the final offset:
JavaScript code:
function readTop(element,amount)
{
if (element.parentNode)
{
amount = amount + readTop(element.parentNode, amount);
}
if (element.offsetTop)
{
amount = amount + element.offsetTop;
}
return amount;
}
function readLeft(element,amount)
{
if (element.parentNode)
{
amount = amount + readLeft(element.parentNode, amount);
}
if (element.offsetLeft)
{
return amount + element.offsetLeft;
}
else
{
return amount;
}
}
elem('error_message_box').style.top = (readTop(elem(id),0) - elem(id).offsetTop)+ 'px';
elem('error_message_box').style.left = (readLeft(elem(id),0) + elem(id).offsetWidth) + 'px';
Works-ish in Firefox, but box is offset roughly 1em down and right, for no apparent reason.
Hmph. Will have to put up with that now because I'm on a deadline, but if anyone has any better solutions they would be greatly appreciated!
EDITED: 30 Nov 2006 17:23 by BOUGHTONP