Javascript Gotcha

offsetTop
element.offsetTop does different things in gecko than IE, best bet is to use the function listed here: http://www.quirksmode.org/js/findpos.html, the code:

function findPos(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return [curleft,curtop];
}

blog comments powered by Disqus