学习在线答疑系统遇到的问题
var zdcount=0;//遮挡物隐藏计数器
function getElementPos(elementId)
{
var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera') != -1);
var isIE = (ua.indexOf('msie') != -1 && !isOpera);
// not opera spoof
var el = document.getElementById(elementId);
if(el.parentNode == null || el.style.display == 'none')
{
return false;
}
var parent = null;
var pos = [];
var box;
if(el.getBoundingClientRect)
{ //IE
box = el.getBoundingClientRect();
var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
return {x:box.left+ scrollLeft, y:box.top + scrollTop,w:box.right-box.left,h:box.bottom-box.top};
}
else if(document.getBoxObjectFor)
{ // FireFox
box = document.getBoxObjectFor(el);
var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;
pos = [box.x - borderLeft, box.y - borderTop,box.width,box.height];
}
else
{
// safari & opera
pos = [el.offsetLeft,el.offsetTop,el.offsetWidth,el.offsetHeight];
parent = el.offsetParent;
if (parent != el)
{
while (parent)
{
pos[0] += parent.offsetLeft;
pos[1] += parent.offsetTop;
parent = parent.offs