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).
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.






Recent Comments