Last Updated: February 25, 2016
·
781
· causztic

event is not defined on Firefox with Filepicker

I was writing a piece of code with a cropper and filepicker and wanted to update the cropper with the uploaded file so that users can manipulate it immediately.

The image url is stored on event.fpfile.url, so I tried accessing it with this method

$(document).on("change", cover_img, function(){
placeholder = "cover-img";
$(placeholder).attr("src", event.fpfile.url + '/convert?"');
... });

...which works on all browsers...except Firefox :\

I read up that Firefox is the only browser that does not have the global event variable, so I tried passing in like

function(event){ event.fpfile.url ... }

and via accessing window.event..no dice.

However, doing it like

function(event){ event.originalEvent.fpfile.url ... }

works! throws confetti

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside