admin管理员组

文章数量:1267930

Please suggest possible techniques to trigger events in parent page from an iFrame. I tried out url Hashing and using window.postMessage techniques but without any success.

Please suggest possible techniques to trigger events in parent page from an iFrame. I tried out url Hashing and using window.postMessage techniques but without any success.

Share Improve this question edited May 2, 2011 at 6:01 Gabe 86.8k12 gold badges143 silver badges238 bronze badges asked May 5, 2010 at 7:51 SKRSKR 8134 gold badges20 silver badges33 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

easyXDM is designed for this exact purpose. You can find it at http://easyxdm and it has quite a few examples.

To sum it up, it allows two windows to municate 'freely' using either strings or RPC calls.

See http://consumer.easyxdm/current/example/methods.html for one of the RPC-demos.

No success because you cannot for security reasons.

The modern answer to this question is the new cross-document messaging (Web Messaging API)

See Opera's introduction here:

http://dev.opera./articles/view/window-postmessage-messagechannel/

Or the specification here: http://www.w3/TR/webmessaging/

The only idea that es to mind is to have a script on server side that the iFrame sends its events to (bined with a unique ID) and that the parent page can poll (either through a server script on its domain, or JSONP). That's a lot of work to do, though, and requires cooperation from both the parent page and the iframe.

本文标签: javascriptPossible Ways to Communicate Between iFrame and Parent Page across domainsStack Overflow