fix for browsers (older webkit and phantomjs) not supporting onloadend #1169

This is a work in progress