Library which bridges the crossdomain execution of javascript
posted: 25 Apr 2012
Library to help bridge the communication gap between domains. Execute crossdomain javascript functions from within your sandbox. While you are at it, execute crossdomain and cross user-agent as well. ;)
Dependent files Make sure the following files and folder remain together:
cmdproxy.js
cmdproxy.swf
swfobject
domain1
Include the following snippet into your source html code. Preferably before the closing </head> tag.
Expose function/s to be called.
domain2
Same steps taken as in domain1.
Expose function/s
You noticed everything is pretty much the same with the exception of the _c configuration variable. The values for each key are important for successful communication.
path location of the cmdproxy library
pub tells the proxy what channel to broadcast to
sub tells the proxy what channel to listen to
Usage
domain1 -> domain2
To execute sayHi function on domain2 from domain1:
cbridge._cmdProxy([“sayHi”]);
domain1 <- domain2
To execute hello function on domain1 from domain2
cbridge._cmdProxy([“hello”, “world”]);
See an implementation in action :^P>
----
[domain1] [domain2]