Changed to document.createEvent

This makes it work in all browsers (IE seemed to actually need it). Already worked in FF en Chrome.