接下来的代码在FireFox和Chrome中运行。当我在IE中运行时出现什么错误?



我正在尝试获取一个元素弹跳框,如下所示:

var bboxRealDibujo = gRootDibujo.getBoundingClientRect();           //El bbox del dibujo.
var bboxRealVentanaDeZoom = ventanaDeZoom.getBoundingClientRect();  //El bbox de la ventana de zoom.
console.log ("Lienzo XY: "+bboxRealDibujo.left+", "+bboxRealDibujo.top+"     /     Lienzo WH "+ bboxRealDibujo.width+", "+bboxRealDibujo.height);
console.log ("Ventana Zoom XY:"+bboxRealVentanaDeZoom.left+", "+bboxRealVentanaDeZoom.top+"     /     Lienzo WH"+ bboxRealVentanaDeZoom.width+", "+bboxRealVentanaDeZoom.height);

正如您在附图中看到的,我在Firefox/chrome中没有任何问题,但是在IE中,变量x,y返回为"未定义"(也尝试使用左,顶部,相同的结果(。

问题是:是类型命令错误,还是IE有自己的命令(像往常一样(?

提前谢谢。

在此处输入图像描述

根据MDN的说法,IE支持getBoundingClientRect,但它不支持xy属性。

IE 和 Edge 返回一个 (ClientRectList with( MSDN:不包含 x 和 y 属性的 ClientRect 对象,而不是 DOMRect 对象

另一种方法是分别使用rect.leftrect.top,而不是xy

最新更新