javascript中offset什么意思啊?如下arguments.callee.offset中offset的具体含义是什么啊,function getvalue(){if(typeof arguments.callee.offset!="numbers"){}}

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 22:13:33

javascript中offset什么意思啊?如下arguments.callee.offset中offset的具体含义是什么啊,function getvalue(){if(typeof arguments.callee.offset!="numbers"){}}
javascript中offset什么意思啊?如下arguments.callee.offset中offset的具体含义是什么啊,
function getvalue(){
if(typeof arguments.callee.offset!="numbers"){}
}

javascript中offset什么意思啊?如下arguments.callee.offset中offset的具体含义是什么啊,function getvalue(){if(typeof arguments.callee.offset!="numbers"){}}
/*不知道楼主的程序是要做什么……不过我看到offset首先想到css的偏移量.
callee 属性是 arguments 对象的一个成员,该属性仅当相关函数正在执行时才可用.
callee 属性的初始值是正被执行的 Function 对象.这将允许匿名函数成为递归的.
*/

/*IE、Firefox3及更高和Opera9.5及更高为每一个元素提供了一个getBoundingClientRect()方法.这个方法返回一个矩形对象,含4个属性:left、top、right和bottom.这些属性给出了元素在页面中相对于视口的位置.但IE认为左上角坐标为(2,2),其他浏览器认为是(0,0).
*/ 

//所以我用过的方法是这样的(获取元素大小):
function getBoundingClientRect(element){ 
var scrollTop = document.documentElement.scrollTop; 
var scrollLeft = document.documentElement.scrollLeft; 

    if(element.getBoundingClientRect){ 
        If(typeof arguments.callee.offset != "number"){ 
            var temp = document.createElement("div"); 
            temp.style.cssText = "position:absolute;left:0;top:0;"; 
            document.body.appendChild(temp); 
            arguments.callee.offset = -temp.getBoundingClientRect().top - scrollTop; 
            document.body.removeChild(temp); 
            temp = null; 
        } 
    
        var rect = element.getBoundingClientRect(); 
        var offset = arguments.callee.offset; 
    
        return{ 
            left: rect.left + offset, 
            right: rect.right + offset, 
            top: rect.top + offset, 
            bottom: rect.bottom + offset 
        }; 
    }else{ 
        var actualLeft = getElementLeft(element); 
        var actualTop = getElementTop(element); 
    
        return{ 
            left: actualLeft - scrollLeft, 
            right: actualLeft + element.offsetWidth - scrollLeft, 
            top: actualTop - scrollTop, 
            bottom: actualTop + element.offsetHeight - scrollTop 
        } 
    } 
}