Skip to content

Instantly share code, notes, and snippets.

@daniel-nelson
Created February 29, 2012 18:58
Show Gist options
  • Save daniel-nelson/1943546 to your computer and use it in GitHub Desktop.
Save daniel-nelson/1943546 to your computer and use it in GitHub Desktop.
Cross-domain iframe communication for modern browsers + IE8
if (typeof(window.postMessage) == 'function') {
window.frames['frame_name'].postMessage(message, '*');
} else if (typeof(window.postMessage) == 'object') {
window.setTimeout(function() {
window.frames['frame_name'].postMessage(message, '*')
}, 0);
}
if (typeof window.postMessage == 'function') {
window.removeEventListener('message', receiveMessage, false);
} else if (typeof window.postMessage == 'object') {
window.detachEvent('onmessage', receiveMessage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment