备忘录只文件下载功能
来源:互联网 发布:visio绘制网络拓扑图 编辑:程序博客网 时间:2024/05/21 13:57
down_file:function(files){
var DownFile = is_ie ? downloadFile : IEdownloadFile;
// 判断类型,处理下载文件名 if(files instanceof Array) { for(var i = 0, l = files.length; i < l ; i++) // bug 处理 DownFile(parseURL(files[i]), files[i], true); } else if(typeof files === "string") { DownFile(parseURL(files), files); } else { // 对象 for(var file in files) DownFile(file, files[file]); } },
(function ($){
var is_ie = !/Trident|MSIE/.test(navigator.userAgent);
function parseURL(str){
return str.lastIndexOf(“/”) > -1 ? str.slice(str.lastIndexOf(“/”) + 1) : str;
};
function downloadFile(fileName, contentOrPath){
var aLink = document.createElement(“a”),
evt = document.createEvent(“HTMLEvents”),
isData = contentOrPath.slice(0, 10) ==”“,
isPath = contentOrPath.lastIndexOf(“.”) > -1;
evt.initEvent(“click”);
aLink.download = fileName;
aLink.href = isPath || isData ? contentOrPath:URL.createObjectURL(new Blob([contentOrPath]));
aLink.dispatchEvent(evt);
};
function IEdownloadFile(fileName, contentOrPath, bool){
var isData = contentOrPath.slice(0, 30) ==”_mainList”,
ifr = document.createElement(‘iframe’);
ifr.style.display = ‘none’;
ifr.src = contentOrPath;
document.body.appendChild(ifr);
isData && ifr.contentWindow.document.write(“”);
if(bool){
ifr.contentWindow.document.execCommand(‘SaveAs’, false, fileName);
document.body.removeChild(ifr);
} else {
setTimeout(function(){
ifr.contentWindow.document.execCommand(‘SaveAs’, false, fileName);
document.body.removeChild(ifr);
}, 0);
}
};
);
- 备忘录只文件下载功能
- 实现文件下载功能
- 文件下载功能
- 文件下载功能
- 实现文件下载功能
- php文件下载功能
- 文件下载功能
- 文件下载功能
- 文件下载功能
- 文件下载小功能
- PHP文件下载功能
- js下载文件功能
- Swing文件下载功能
- 文件下载功能
- PHP 文件下载功能
- 文件下载功能
- electron 下载文件功能
- 实现只允许注册用户下载文件
- SWT GridLayout网格式布局
- win7安装使用mosquitto,vs2010中使用libmosquittopp
- MPU6050对卡尔曼、一阶互补滤波、二阶互补滤波的比较
- FZU Problem 2140 Forever 0.5(计算几何构造,依旧考查思维)
- 操作系统内存状态与postgresql内存设置
- 备忘录只文件下载功能
- HTML5学习_day05(1)--html浮动之文档布局
- Zookeeper源码分析之二Session建立
- JS写一个函数,找出字符串中出现最多的字符
- LeetCode笔记:404. Sum of Left Leaves
- Java串口通信(16进制)
- WARNING (theano.configdefaults): g++ not detected 解决办法
- Android Studio插件整理 (转载)
- nodejs 循环获取从1到n的图片