JQuery文件下载适用于Chrome但不适用于Firefox

时间:2015-04-07 14:58:38

标签: javascript jquery google-chrome firefox

我有一小段JQuery,它创建一个只包含一个字符串的.M3U文件,然后提示用户下载。这在Chrome中工作正常但在Firefox中没有效果,并且FireFox控制台上不会出现任何错误。有人可以帮忙吗?

function playfile(filepath) {
    var file = document.createElement('a');
    file.setAttribute('href', 'data:text/plain;charset=utf-8,' + decodeURIComponent(unescape(filepath)));
    file.setAttribute('download', "Play.m3u");
    file.click();
}

0 个答案:

没有答案