You can see me scratching my head over on Stack Overflow.
I’ve got some kind of answer, not sure if it’s the right one yet. Will keep you posted when it’s in the repository.
Update : OK. It’s up on GitHub. Would welcome feedback if it’s now working. (Safari on Mac, IE on Windows, Chrome on Windows etc.)