How to change default file name to save to file in FF using HTML and JS?
The simple answer is that we cannot.
Names are generated inside the browser, and we do not have access to the API from a regular web page, and therefore they cannot change this behavior.
There are several reasons for not having direct access to the default context menu, one of which is safe.
Extensions
One of the tasks is to create a plug-in / extension for the browser and provide a custom context menu item that can then give the desired behavior.
Or use some existing ones, such as this or this - this is a random selection, just for example. You might be better off with add-on collections.
Download attribute and context menu
If you control the page from which you want to save images, you can also provide a custom context menu that allows you to save images using the A tag and the download attribute, which allows you to set the file name.
You will need to convert the image to an Object-URL or Data-URI and set it as the source for tag A.
Some may object to using custom context menus for various reasons, but if it is for local use, there is no good reason to say that you cannot, and in other cases a good UX approach can inform the user about this behavior, removing any surprises.
Context Menu Example Using CamanJS
A minimalist example is added to display a menu with a link and a file name. The example uses the CamanJS method using the toBase64() method.
Since CamanJS replaced the original element, it is important to attach event handlers after the canvas has replaced them, because otherwise the handler will die with the original element in the sense that they are no longer available.
Caman(img, function() { var me = this;
#menu { position:fixed; background:#444; padding:4px 7px; box-shadow:3px 3px 3px #000; display:none; } #menu a {color:#fff;font:14px sans-serif}
<script src="http://cdnjs.cloudflare.com/ajax/libs/camanjs/4.0.0/caman.full.min.js"></script> <img id=img src="//i.imgur.com/67E6Ujdb.jpg" crossOrigin="anonymous"> <div id="menu"> <a id="lnk"></a> </div>
NOTE: may not work in Stacksnippet with Firefox (it seems like a problem with Stacksnippet). Here is an alternative to a script link .