How to stop a link from launching

Hi, I have an older XUL extension that runs on Firefox 45. I have it capturing a download link that the user is clicking. How can I stop the actual download from happening?
I have tried: “event.stopPropagation()”, but Firefox still launches the “save” dialog. I even tried “window.event.stopPropagation()” but that gave an error. Can someone tell me how I can stop the browser from firing off the save dialog?

you want to event.preventDefault() and not stop propagation.

Thanks, but that did not stop the save file dialog from popping up.

Another possible solution is to return false; from the event listener, though I’m not sure if that’s supposed to work better than preventDefault. If that doesn’t help I’m not sure you’re listening for the correct event that is triggering the download.

HI, so I have a link on my page:
a href=“http://localhost:62741/TestDownload.aspx

This link will call TestDownload.aspx which will serve up a download. (png file)
I have written an extension that captures the mouse up event. Checks to see if that particular link is clicked and if so, handles the download.

What event should I be listening for in order to stop the Firefox download popup from launching?

you need to listen to the click or mousedown events, since mouseup fires after the download has been started (or any mouse action was started, in fact).

Thanks so much. That worked.