Skip to content

Instantly share code, notes, and snippets.

@amccloud
Created February 6, 2013 17:46
Show Gist options
  • Save amccloud/4724370 to your computer and use it in GitHub Desktop.
Save amccloud/4724370 to your computer and use it in GitHub Desktop.
(function() {
'use strict';
var cacheBust = 0,
hashInterval,
lastHash;
this.xd = {
postMessage: function(message, targetOrigin, otherWindow) {
if (!targetOrigin)
return;
otherWindow = otherWindow || window.parent;
otherWindow.postMessage(message, targetOrigin.replace(/([^:]+:\/\/[^\/]+).*/, '$1'));
},
onMessage: function(callback, origin) {
if (window.addEventListener) {
window[callback ? 'addEventListener' : 'removeEventListener']('message', callback);
} else {
window[callback ? 'attachEvent' : 'detachEvent']('onmessage', callback);
}
}
};
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment