简体   繁体   English

在iframe上打开对话框,然后单击

[英]Open dialog on iframe click

I am writing a widget which gets embedded on other pages (on other domains) via an iframe. 我正在编写一个通过iframe嵌入到其他页面(在其他域中)的小部件。 A click anywhere on the widget/iframe should bring up a dialog. 在小部件/ iframe上的任意位置单击都会弹出一个对话框。 The dialog does not fit in the dimensions of the iframe. 该对话框不适合iframe的尺寸。

  • I cannot trigger the dialog from inside the widget/iframe since it will get clipped by the iframe dimensions. 我无法从小部件/ iframe内部触发对话框,因为它将被iframe尺寸限制。

  • A user of the widget also includes a JS from my site. 小部件的用户还包括我网站上的JS。 But I cannot listen to onclick events on the iframe (on the host page) since they aren't any onclick events on an iframe. 但是我无法在iframe上(主机页面上)监听onclick事件,因为它们不是iframe上的任何onclick事件。

What's a good, secure way of resolving this which will reliably work on all modern browsers? 有什么好的安全解决方案可以在所有现代浏览器上可靠地工作?

Have a look at these PostMessage plugins 1 / 2 which allow you to communicate ie pass messages between an iFrame on another domain and the parent page. 看看这些PostMessage的插件, 1 / 2 ,让你沟通即在另一个域的iFrame和父页面之间传递消息。

This means you can listen for the click on the iFrame, then send a message to the parent. 这意味着您可以监听iFrame的点击,然后向父级发送一条消息。 When the parent receives that message, it can then show a dialog 家长收到该消息后,可以显示一个对话框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM