Christian
Christian

Reputation: 21

Override Firefox's Default Filename in the "Save Page As" Dialog

I want to write a Firefox Add-on which removes some special characters from the default filename (highlighted in red in the image below) in the "Save Page As" dialog in Firefox. Does the Firefox SDK API offer some way to alter this filename?

Save Page As dialog in Firefox

Upvotes: 1

Views: 345

Answers (1)

gal007
gal007

Reputation: 7192

Check the defaultString of the nsIFilePicker e.g.

    var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
        .createInstance(nsIFilePicker);
fp.init(window, "Select a File", nsIFilePicker.modeOpen);

    fp.defaultString = defaultString; //Process the string as you want

    fp.appendFilter(fileType, "*." + fileType);
    var rv = fp.show();

Upvotes: 1

Related Questions