Fix #198

This works in Firefox and Firefox OS. Can someone test Chrome?

Credit for the code goes to @twiss.