I think the context version will cause problems when the context isn't set as window. Correct me if I'm wrong on any of the above. Someone with better js knowledge might be able to offer a better suggestion.
I wont be able to reply to anyone until later today.
Also I apologise if the formatting is crap, im typing on my tablet.