【问题标题】:window.parent.postMessage parent check what iframe sent messagewindow.parent.postMessage 父检查 iframe 发送的消息
【发布时间】:2013-08-08 21:04:36
【问题描述】:

我需要知道什么 iframe 向父窗口发送了消息,因为我将在一个 iframe 托管页面上有多个 iframe。

如何检查是哪个帧发送了消息?

【问题讨论】:

    标签: javascript html postmessage


    【解决方案1】:

    您只能检查哪个域发送了邮件。如果您需要更多标识,您可以随时将其分层到您的消息传递系统中。

    发送如下消息:

    message = {
        "source": "menu",
        "message": "click on entry"
    };
    

    每个框架都有自己的来源。您需要序列化消息,JSON 效果很好。

    【讨论】:

      猜你喜欢
      • 2020-02-08
      • 1970-01-01
      • 1970-01-01
      • 2013-10-08
      • 1970-01-01
      • 2019-03-22
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多