2013-10-02 36 views
3

假設我在頁面上有多個iframe,並且其中一個發送了發佈消息。是否有一種簡單的交叉瀏覽方式來檢測哪個人做了它並能夠回覆?檢測哪個iframe發送了發佈消息

我看到消息eventsource財產,但我無法響應通過它使用event.source.contentWindow.postMessage

Error: Permission denied to access property 'contentWindow'

+2

如果有人將尋找的解決方案同樣的問題,我可以分享我發現的。只需將消息中的iframe ID與其他數據一起發送即可。簡單的方法讀取iframe中的iframe的ID的設置與工作期間的「name」屬性和獲取window.name屬性類似。 – user2281966

回答