background preloader

Cross domain iFrames

Facebook Twitter

Gadget to Gadget. This document explains how to use the publish-subscribe ("pubsub") framework to pass messages from one gadget to another.

Gadget to Gadget

This feature is deprecated and is unsupported. The publish-subscribe framework allows publisher gadgets on iGoogle to communicate changes to subscriber gadgets that have declared interest in those changes. Note: You can use the publish-subscribe framework for type="html" gadgets. This feature does not support type="url" gadgets. To use pubsub, your gadgets must be running on iGoogle. Here are the major concepts involved in gadget-to-gadget communication: Publisher. This table lists the channel names that are currently supported. You implement gadget-to-gadget communication through "userprefs binding". The above snippet illustrates how to define userprefs for the pubsub feature: The publisher gadget and the subscriber gadget must have at least one userpref with the same name.

Step 1. Initially, each gadget displays its own default value for the userpref test000. Step 2. YouTube iframe API. Mapplets. IFrames - Cross-Domain Communication. An update in the era of HTML5 (May 6, 2011) This post has been heavily commented and linked to over the years, and continues to receive a ton of traffic, so I should make it clear that much of this is no longer relevant for modern browsers.

IFrames - Cross-Domain Communication

On the one hand, they have adjusted and tightened up their security policies, making some of the techniques here no longer relevant. On the other hand, they have introduced technologies that make it easier to do cross-domain communication in the first place. With modern browsers, you can and should be using postMessage for this purpose. Library support is now available too. Now back to the original post … (from March 31, 2008) This article explains iframe-to-iframe communication, when the iframes come from different domains. Background: Cross-Domain Communication Ironic that in this world of mashups and Ajax, it’s not very easy to do both of them together. Related to this article is a demo application and a couple of variants. The Demo Demo Ta-da!!! Another Cross Domain iFrame. Recently I created a web page that hosted an iFrame.

Another Cross Domain iFrame

The contents of the iFrame were served from another domain. That content would use JavaScript to hide and show some HTML elements. As the iFrame’s content changed, I didn’t want scroll bars to appear or some of the content to be hidden (if I applied scrolling="no"). I could have just made sure the iFrame was big enough to contain the maximum content... but I wanted a more dynamic solution that made the iFrame appear more integrated with its parent page. I needed the parent page to adjust the size of the iFrame as the content size changed. This requires client side, cross domain communication between the iFrame and its parent page.

Basically, a page can change the fragment part of an iFrame’s Location URL (i.e. the part of the URL after the # symbol) without the iFrame reloading. This post by Michael Mahemoff provides a good introduction to both techniques. I’ve hosted an example of this working. How it works… Cross-Browser Comm Demo via 'Marathon' technique.