This should work (I figured this out by looking at the FileSaver.js code):
function onSaveJPG(url,n){ var save = document.createElement('a'); save.href = url; save.download = 'Image no '+n+'.jpeg' || url; var event = document.createEvent("MouseEvents"); event.initMouseEvent( "click", true, false, window, 0, 0, 0, 0, 0 , false, false, false, false, 0, null ); save.dispatchEvent(event); }
(The main problem is that you need to use an event like MouseEvent for firefox, not an event. This code will also work in Chrome).
source share