【问题标题】:iframe.contentDocument.documentElement.scrollHeight - Dart equivalentiframe.contentDocument.documentElement.scrollHeight - Dart 等效项
【发布时间】:2015-02-02 12:42:18
【问题描述】:

final html.IFrameElement iframe = rootDemoElement.querySelector("iframe");
final int contentHeight = <???>.scrollHeight;

这在 JS 中有效:

var contentHeight = iframe.contentDocument.documentElement.scrollHeight;

contentDocument 在 Dart 中不可用。
Dart中是否真的可能缺少contentDocument?

【问题讨论】:

    标签: dart dart-html


    【解决方案1】:

    这是我的解决方案:

    var jsIFrame = new JsObject.fromBrowserObject(iframe);
    var contentHeight = jsIFrame["contentDocument"]["documentElement"]["scrollHeight"];
    

    【讨论】:

      【解决方案2】:

      据我所知,有人试图让浏览器中的 Dart 比 JavaScript 更安全,这导致了跨窗口通信受限的模型(到 postMessage)。我假设 iframe 也有同样的限制。有评论说他们想离开这个策略,因为这通常是通过使用 dart-js-interop 来绕过的。

      我认为主要的罪魁祸首是你得到了 _DOMWindowCrossFrame 而不是 Window 实例。

      可能也相关

      【讨论】:

      • 很高兴听到它有帮助。我希望他们最终会修复它。
      猜你喜欢
      • 1970-01-01
      • 2020-05-09
      • 2021-10-30
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-20
      相关资源
      最近更新 更多