主要解决页面内部动态获取下载文件url后,自动下载的问题。
新开一个标签页下载: window.open(‘url’, ‘_blank’);
这会导致屏幕新开标签页时的闪动,但浏览器兼容性好。
HTML5浏览器中, 可在本标签页中无闪动开启下载:
$('<a href="path_to_file" download="proposed_file_name">Download</a>')[0].click();
path_to_file is either an absolute or relative path, proposed_file_name the filename to save to (can be blank, then defaults to the actual filename).
转载请注明原文地址: https://ju.6miu.com/read-668103.html