Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Brain committed Apr 29, 2016
1 parent 1f0e6f1 commit 9aba90d
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,4 +59,46 @@ postRobot.once('init', function(err, data, callback) {
postRobot.send(window, 'init', function(err, data) {
console.log('init done');
});
```
```

## 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
<script src="http://xx.com/js/post-robot.js"></script>
```

2. In the parent page, `xx.com`, include the following javascript:

```html
<script>
postRobot.openBridge('http://yy.com/bridge.html');
</script>
```

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.

0 comments on commit 9aba90d

Please # to comment.