From 9aba90d23e7128bcec7e21e9d8b0346a88fe271e Mon Sep 17 00:00:00 2001 From: Daniel Brain Date: Fri, 29 Apr 2016 10:32:08 -0700 Subject: [PATCH] Update docs --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b9c6b77..a7266d72 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,13 @@ With this, you can set up a listener in one window, have it wait for a post mess and gracefully handle any errors that crop up. You can also set a timeout, to be sure that the other window is responding to you, and fail gracefully if it does not. +This also allows cross-domain post messages between two different windows (not just popups) in IE9+. + ## Features - Request/response pattern (avoids sending fire-and-forget messages back and forth) - Don't worry about serialization, just send javascript objects +- Handles all of the corner cases for IE9+, which is normally not able to send cross-domain post messages between two different windows, only iframes - Handle error cases gracefully - The user closed the window you're trying to message - You sent a message the other window wasn't expecting @@ -56,4 +59,46 @@ postRobot.once('init', function(err, data, callback) { postRobot.send(window, 'init', function(err, data) { console.log('init done'); }); -``` \ No newline at end of file +``` + +## IE9+ + +In order to use post-robot in IE9+ between two different windows on different domains (like a parent window and a popup) +you will need to set up an invisible bridge in an iframe on your parent page: + +``` ++---------------------+ +| Parent xx.com | +| | +--------------+ +| +---------------+ | | Popup yy.com | +| | Bridge yy.com | | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | +| | | | +--------------+ +| +---------------+ | +| | ++---------------------+ +``` + +Doing this is pretty simple: + +1. Create a bridge path, for example `http://yy.com/bridge.html`, and include post-robot: + +```html + +``` + +2. In the parent page, `xx.com`, include the following javascript: + +```html + +``` + +Now `Parent xx.com` and `Popup yy.com` can communicate freely using post-robot in IE. + +This can even be done in reverse -- for example, `Popup yy.com` can include `Bridge xx.com` if that suits your use cases better. \ No newline at end of file