【发布时间】:2014-11-24 21:00:21
【问题描述】:
已经编写了这段代码,它在谷歌浏览器上运行完美,但在 Firefox 上运行不正常,你有什么线索吗?
预期的行为是您将 xml 文本和名称作为参数传递,它会下载一个带有该 xml 文本和您发送的名称的 xml 文件,正如我所说,对于 chrome 可以,但对于 firefox,它不会下载吧。
/** * 从查询结果的选定行创建和下载文件 * @param xml文本 * @param 文件名 */
函数 createAndDownloadFile(xmltext, 文件名){
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();
}
【问题讨论】:
标签: javascript xml firefox