Monthly Archive for July, 2009

Cross-domain Dynamic iFrame resizing based on iFrame contents

Was facing this age old problem and googling around when I came across an excellent article at http://www.julienlecomte.net/blog/2007/11/31/ using the Yahoo cross-frame javascript library. For detailed description of how the cross-frame js works, head over to the excellent blog and read the article.

Did up a quick demo at http://www.alvinzhang.com/page.html. Simply view source, its very simple and straightforward, using a proxy as the communicator to bypass the cross-domain restrictions. Send the updated height across and set the iframe height to the new height.

Proxy and cross-frame.js can be downloaded here.

The article was written back in 2007 but still works perfectly now with the modern browsers in 2009. I would actually prefer something more familiar with flash developers like a crossdomain.xml which would be great.

Update 21 July: I just found out that HTML5 has support for cross-document messaging which makes it possible to do dynamic iframe resizing in a more elegant manner (less hack-ish).

Read: http://developer.apple.com/safari/library/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Articles/Cross-documentmessaging.html

Incidentally, I came across this article while I was researching on the issue where Safari (is the only browser which) doesn’t allow an iframe containing content from an external domain to set cookies.

Post any questions in comments and I’d be glad to help out.

Fund Raising for Charmaine has reached target!

I just dropped by the blog for the above banner which is attempting to raise funds for a little girl Charmaine who is down with neuroblastoma and found out that they have managed to raised the target amount of funds which means that Charmaine will be able to fly to New York for her treatment. Cheers for that! And continue to pray for this little girl for a successful treatment.