Cross domain messaging made easy with
$ component install cayasso/postmessage
Or you can just grab the postmessage.js bundle file and include it in your page:
var target = documentcontentWindow;var pub = ;var sub = target;sub;pub;
var pub = ;var sub = ;sub;
This method return a postmessage
type, this can be
pub for publishing or
sub for subscribing.
var Pub = ;var Sub = ;
Create a publisher instance, a target window can be passed as first argument, if none the target
window will be
var Pub = ;var pub = ;
Target window setter and/or getter, if no argument is passed it will get the current target window, else it will set a target window.
pubtargettargetWindow;// get the current target windowvar target = pubtarget;
Target origin setter and/or getter, if no argument is passed it will get the current target origin, else it will set a target origin.
pub;// get the current target windowconsole; // ->
target window and
origin to defaul values.
pub;// reset publisherpub;// get the current target windowconsole; // -> '*'
Send a message to a target window. You can pass the target and origin as second and third parametters correspondingly.
// data is serialized by JSONpub;// or with specifying the origin:pub;// or with a target window:pub;
Create a subscriber instance, a window can be passed as first argument, if none the default
window will be
var Sub = ;var sub = ;
Add origin domains to white list.
Bind or subscribe to post messages for the specified window.
Unbind or unsubscribe from window post messages. If no funciton is passed it will unbind all listeners.
// unbind by passing the pointer functionsub;// unbind all listenerssub;
This unbind all listeners from subscriber and then destroy it.
First in the root directory do:
$ npm install
Then run the test like this:
$ make test
(The MIT License)
Copyright (c) 2013 Jonathan Brumley <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.