easyXDM is a javascript library that uses available techniques to provide a means of transporting messages and/or method calls between windows in different domains, in short, by-passing the same-origin policy and letting you call methods across the domain boundry.

This is perfect if you plan to provide a client-side API (e.g Facebook Connect) on your web site as you can expose a method in as little as 7 lines of code.

var remote = new easyXDM.Interface({}, { local: { doMagic:{ method: _privateMethod } } });

This can be consumed by a client by using

var remote = new easyXDM.Interface({ local: "../hash.html", remote: "http://apiprovidersdomain.com/api.html" },{ remote: { doMagic: {} } });

and can then be called by using

remote.doMagic('argument1',2,function(result){ alert(result) }

In this CodeProject article I present an example on how easy it is to do this, and in the extensive documentation there are links to several demos showing everything from sending simple strings to letting two applications from different domains send arbitrary objects back and forth, even using older browsers like IE6.

The demos are repeated here

This library was earlier on called easyXSS, but due to the name being kinda ambiguous (someone say vulnerability), I decided to change it to easyXDM, short for easy cross domain messaging.

If you want to sneak a peek at the sourcecode, you can see the fully documented debug version here. The minified version weighs in at only 1.46KB gzipped.

The library is very flexible, allowing you you choose exactly how much of the work you want to handle yourself, the base functionality is transferring string messages.

Some of the features are

transport classes for transmitting strings postMessage where supported OR hash fragment using the resize event for invisible iframes hash fragment using polling for visible frames

channel class for transmitting aribitrary data

interface class for setting up methods to be exposed/consumed

debug build with extensive logging for easy debugging

works in all browser (run the test suite)

The library also support both visible and invisible iframes, so you can either access the aussies casino online remote domain transparently, or you can expose the remote domains document for direct interaction (sign in etc.).

<ul>

<li>

<a href=”http://consumer.easyxdm.net/example/transport.html”>Sending plain string messages using the easyXDM.Transport.BestAvailableTransport class</a>

</li>

<li>

<a href=”http://consumer.easyxdm.net/example/data.html”>Sending data (objects) using the easyXDM.Channel class</a>

</li>

<li>

<a href=”http://consumer.easyxdm.net/example/methods.html”>Exposing and invoking methods using the easyXDM.Interface class</a>

</li>

<li>

<a href=”http://consumer.easyxdm.net/example/xhr.html”>Calling an ajax method from the remote domain</a>

</li>

<li>

<a href=”http://consumer.easyxdm.net/example/index.html”>Bridging two web applications</a>

</li>

</ul>