window.location.href下载文件,文件名中文乱码处理

下载文件方法:

window.location.href='http://www.baidu.com/down/downFile.txt?name=资源文件';

这种情况下载时:文件名资源文件会中文乱码,解决办法:encodeURI(fileUrl, "utf-8");

var newFileUrl=encodeURI('http://www.baidu.com/down/downFile.txt?name=资源文件', "utf-8");

window.location.href=newFileUrl;

 

posted @ 2019-08-02 11:29  常威打来福  阅读(6920)  评论(0编辑  收藏  举报