In a DART website/component that is in an iFrame, how can I query elements of the parent window?

本小妞迷上赌 提交于 2019-12-08 07:42:26

问题


collegues,

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.

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.

Now the QUESTION:

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)

Thanks in forward


回答1:


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.

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



来源:https://stackoverflow.com/questions/23404768/in-a-dart-website-component-that-is-in-an-iframe-how-can-i-query-elements-of-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!