Monday, April 22, 2013

Cross-domain Communication .... for IE7 as well

While implementing Shopping Community feature, we need to have an iframe on merchant's site that shows the activity feed. As I told in the previous post, scroll bar in the iframe looks so ugly that we decided to have change the size of iframe based on the content inside the iframe.

This called for cross domain communication as the iframe was included on the retailer's website. On Googling we found 2 methods. One using iframes and other using html5 postmessage method.

As most of the browsers now (including IE9) support HTML5, we decided to go with it.

For IE7 and IE8, we implemented some hack exploiting Microsoft's old implementation of postmessage in IE that was different from the current standards.

Later we found a very good library called EasyXDM. The library supports many more browser versions. It adopts the implementation based on available features in the browser. For example, if it is a morden browser and postmessage is implemented in the standard way, it uses or it uses flash based implementation. More can be found in EasyXDM Readme at Github.