IFRAME as a side-channel

2009-09-10 @ 21:06#

yeah, i know the IFRAME is evil, ya-da, ya-da, ya-da. but i find them quite handy.

one way i use the IFRAME is to implement a side-channel that can be used to perform tasks that normally result in a "post-away" in common Web browsers. this side-channel lets me support UI patterns that keep the user focused on the current page while doing some other task in the background.

for example, i use an IFRAME side-channel to handle file downloads:

<form method="get" action="/downloads/zipset" target="hidden_iframe">
  <input type="hidden" name="zip-id" value="C252B6EB-2B6C-4CAE-B045-B050EA834666">
  <input type="hidden" name="transaction-ticket" value="a1s2d3f4g5h6j7k8">
  <input type="submit" value="Download" />
</form>

when a user activates the "Download" button, instead of navigating the user to the server-side URI, the browser pushes the request into the IFRAME. the user will see the browser download dialog pop up without leaving the current page.

simple, easy, effective.

code