在iFrame中的DART网站/组件中,如何查询父窗口的元素? [英] In a DART website/component that is in an iFrame, how can I query elements of the parent window?

查看:138
本文介绍了在iFrame中的DART网站/组件中,如何查询父窗口的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

collegues,

collegues,

我正在解决我之前的 ISSUE 我遇到了一些涉及影子DOM和重度JS动画的性能问题。

I'm solving my previous ISSUE where I had some performance issues involving the shadow DOM and heavy JS animations that were not done in DART.

建议的解决方案是将我的DART组件移动到iFrame,将shadowDOM限制为只有iFrame的DOM。

The proposed solution for this was to move my DART component into an iFrame, to restrict the shadowDOM to the DOM of only that iFrame.

现在的问题:

如何从我的DART代码元素中查询JS:window.parent?任何想法如何可以注册监听器onclick的父iFrame上的元素? (我也使用Polymer)

How can I query from my DART code elements from JS:window.parent? Any ideas on how can I register listeners to onCLick of elements on the parent iFrame? (I'm using Polymer as well)

感谢在前进

推荐答案

p> Dart通常不会将DOM暴露在iframe边界之外。你可以通过postMessage进行通信。我建议在iframe里面听点击,然后从该处理程序中向window.parent发布一条消息。

Dart generally doesn't expose the DOM across iframe boundaries. You can communicate via postMessage though. I would suggest listening for "click" inside the iframe, then from within that handler, post a message to the window.parent.

这篇文章中的例子在其他方向(Dart托管一个JS子项iframe),但它可能是有帮助的:
http://japhr.blogspot.com/2013/05/a-necessary-evilgood-in-dart-iframe.html

The example in this post goes in the other direction (Dart hosting a JS child iframe), but it might be helpful: http://japhr.blogspot.com/2013/05/a-necessary-evilgood-in-dart-iframe.html

这篇关于在iFrame中的DART网站/组件中,如何查询父窗口的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆