Access to file download dialog in Firefox

前端 未结 11 2609
一个人的身影
一个人的身影 2020-11-22 07:02

Is there any kind of API that can allow me to manipulate a file download dialog in Firefox? (I want to access the one that appears when user does something, not initiate one

11条回答
  •  轮回少年
    2020-11-22 07:31

    I had the same problem, I wanted no access of Save Dialogue.

    Below code can help:

        FirefoxProfile fp = new FirefoxProfile();
        fp.setPreference("browser.download.folderList",2);
        fp.setPreference("browser.download.manager.showWhenStarting",false);
        fp.setPreference("browser.helperApps.alwaysAsk.force", false);
        // Below you have to set the content-type of downloading file(I have set simple CSV file)
        fp.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");
    

    According to the file type which is being downloaded, You need to specify content types.

    You can specify multiple content-types separated with ' ; '

    e.g:

        fp.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv;application/vnd.ms-excel;application/msword");
    

提交回复
热议问题