Here is a solution I come up with:
offsetRight = elem.offsetWidth - elem.clientWidth - elem.clientLeft; offsetBottom = elem.offsetHeight - elem.clientHeight - elem.clientTop;