这是一个简单的DART代码,可以在Chrome和FF中完美运行,但在IE10中会引发异常:

import 'dart:html';

RangeInputElement inputPageSlider;

void main() {
  inputPageSlider = new RangeInputElement();
  inputPageSlider..id="pageslider"
      ..className="leftFill ddrintslider"
      ..style.display="inline-block"
      ..style.whiteSpace="normal"
      ..style.marginTop="14px"
      ..style.width="82%"
      ..style.height="1px"
      ..style.marginLeft="auto"
      ..style.marginRight="auto"
      ..value = '1'
      ..name="pageslider" ;


  print(inputPageSlider.getBoundingClientRect().width);
  print(inputPageSlider.getBoundingClientRect().left);

}

这是异常(exception):
SCRIPT16389: Unspecified error.
ietest.dart.js, line 971 character 1

和代码:
966: J.Fm(z.style,"auto")
967: J.GL(z.style,"auto")
968: y=J.RE(z)
969: y.sP(z,"1")
970: y.soc(z,"pageslider")
971: P.JS(J.DO($.i9.getBoundingClientRect()))
972: P.JS(J.hs($.i9.getBoundingClientRect()))}},1],])
973: I.$finishClasses($$,$,null)

访问inputSlider.contentEdgeinputSlider.borderEdge也会发生相同的问题。

这是一个已知的错误?

最佳答案

您的代码表明您没有将元素添加到DOM。我猜想IE在这里更加严格,因为不在DOM中的元素没有客户端。

当我将元素添加到主体时,我将得到一个矩形。

您可以改用getClientRects()。这将返回一个空列表,而不是引发异常。

问候
罗伯特

关于javascript - Dart-IE10中的getBoundingClientRec()上的异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23916094/

10-09 20:31
查看更多