Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用原型的偏移高度_Javascript_Css_Prototypejs - Fatal编程技术网

Javascript 使用原型的偏移高度

Javascript 使用原型的偏移高度,javascript,css,prototypejs,Javascript,Css,Prototypejs,我从InternetExplorer8和Firefox3.5中Prototype的cumulativeOffset函数中得到了不同的值,该函数位于一个复杂的布局中,有几个元素具有填充和边距 这似乎是一个已知的错误: 有人知道可靠确定静态定位元件偏移高度的基于原型或与原型兼容的方法吗?这是原型开发团队成员之一的图 您可以添加视口偏移和滚动偏移,但我不确定这是否会包含相同的问题 大多数情况下,我都使用它来查找元素位置: function findPos(obj) { //find coor

我从InternetExplorer8和Firefox3.5中Prototype的
cumulativeOffset
函数中得到了不同的值,该函数位于一个复杂的布局中,有几个元素具有填充和边距

这似乎是一个已知的错误:

有人知道可靠确定静态定位元件偏移高度的基于原型或与原型兼容的方法吗?

这是原型开发团队成员之一的图

您可以添加视口偏移和滚动偏移,但我不确定这是否会包含相同的问题

大多数情况下,我都使用它来查找元素位置:

function findPos(obj) {
    //find coordinates of a DIV
    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];
}
这是一张来自的图表,他是原型开发团队的成员之一

您可以添加视口偏移和滚动偏移,但我不确定这是否会包含相同的问题

大多数情况下,我都使用它来查找元素位置:

function findPos(obj) {
    //find coordinates of a DIV
    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];
}

quirksmode脚本运行良好,我想我会使用它。谢谢对于任何可能不知道的人来说,Quirksmode是jQuery背后的人的博客,所以当它是一个选项时直接使用jQuery将产生类似的结果(可能使用相同的代码进行测量)。Quirksmode脚本在FF/IE/Chrome上对我来说运行良好,直到我为其添加了一个边框顶部。然后,我在FF/IE/Chrome中得到了完全不同的(!)值:(quirksmode脚本运行良好,我想我会使用它。谢谢!对于任何可能不知道的人,quirksmode是jQuery背后的人的博客,所以当它是一个选项时直接使用jQuery将产生类似的结果(可能使用相同的代码进行测量)是一个公平的赌注).quirksmode脚本在FF/IE/Chrome中运行良好,直到我在其中添加了边框。然后我在FF/IE/Chrome中获得了完全不同的(!)值:(