File Download on Javascript does not work on firefox



have written this piece of code which is working perfect on Google Chrome but not working on Firefox, do you have a clue?


The expected behavior is that you pass as parameters a xml text and a name and it downloads a xml file with that xml text and with the name you sent, as I said, for chrome is ok but for firefox, it does not download it.


/** * Creates and download a file from a selected row on query results * @param xmltext * @param filename */


function createAndDownloadFile(xmltext, filename){



var pom = document.createElement('a');
//creates a blob variable with the xml text
var bb = new Blob([xmltext], {type: 'text/xml'});

//sets the atribute href
pom.setAttribute('href', window.URL.createObjectURL(bb));
pom.setAttribute('download', filename);

//creates the download url
pom.dataset.downloadurl = ['text/xml', pom.download, pom.href].join(':');
pom.draggable = true;
pom.classList.add('dragout');

//apply the click on to download the file
pom.click();


}


No comments:

Post a Comment