Iframes and Javascript

2007 Nov 25 - Gabrys

Hi All!

We've been working hard on introducing OpenSocial to ourselves and on many other things somehow connected to Wikidot.com. Last Saturday we were in Warsaw at a BarCamp 7.11 meeting, presenting Wikidot.com and its development plan for the near future.

One of the key features we will support is OpenSocial integration. Probably we'll be a one of the very first wiki to do it! This is because Wikidot.com is much more about building communities than many other wikis.

To allow arbitrary JavaScript execution we'll sandbox OpenSocial widgets in iframes using different domains for them (like os.wikidot.com) and very special server-side scripts. This will prevent from creating OpenSocial applications that will execute any Wikidot.com JavaScript (like batch-commenting articles or deleting users accounts). Our users are safe.

The issue that's left to solve is adjusting iframe height to the height of the iframe's content. Being it really easy for simple domain installation, it becomes quite tricky to implement having the restrictions of modifying nodes attributes between different domains. This is still to solve. One possible solution would be tracking iframe content height changing in iframe and transmitting it to the server and let it transmit it to the parent site. Sounds complicated and, yes, it has some cons.

The simplest way to achieve that using server-side software would work like this:

  • a site http://abcdef.wikidot.com/ embeeds an OpenSocial widget
  • the widget is displayed as an iframe with 0 height, URL is http://os.wikidot.com/something
  • the site sends a query (HTTP XML Request or similar AJAX) about the desired height of the iframe to the server
  • when iframe loads its content it sends the body height to the server
  • the server sends a response to the site with the desired height of the iframe
  • the site sets iframe height according to the server's responce

Additionally after setting the iframe height, we would query the server about new height again. The server, however, will answer only when the document height changes inside the iframe.

Backlinks

Recent Posts

Comments

Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License