Skip to content

Instantly share code, notes, and snippets.

@rmanalan
Created June 15, 2010 21:46
Show Gist options
  • Select an option

  • Save rmanalan/439786 to your computer and use it in GitHub Desktop.

Select an option

Save rmanalan/439786 to your computer and use it in GitHub Desktop.
// http://shouldersofgiants.co.uk/Blog/post/2009/08/17/Another-Cross-Domain-iFrame-Communication-Technique.aspx
// Forward message to the "real" iFrame that should be
// hosted somewhere in the parent page
function getFrame(name){
for(var i=0;i<parent.frames.length;i++) {
if (parent.frames[i].name == name) return parent.frames[i];
}
}
function ForwardMessage() {
var wcirbmif = getFrame("wcirbmif");
wcirbmif.onMessageFromParent();
}
// Hook up the Forward Message dependent on browser. FF will only raise the
// resize event on the window / body.
if (window.addEventListener){
window.addEventListener('resize', ForwardMessage, false);
} else if (document.body.attachEvent){
window.attachEvent('onresize', ForwardMessage);
}
// Ensure ForwardMessage is called once after the page is loaded so that
// any message sent during page load is eventually passsed on. Particularly
// needed if you are looking at resizing content.
setTimeout('ForwardMessage', 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment