1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <br> //下载时加载的操作 load = function () { down_windows = layer.msg( "数据正在下载中" , { icon: 16, shade: 0.3, time: -1 }); } //下载完成后触发,用来关闭提示框 disload = function () { layer.close(down_windows) } // 下载使用的方法 getDownload = function (url) { var xhr = new XMLHttpRequest(); if ( typeof (xhr) != "undefined" ) { // 现在使用的方法 可在下载完成的时候关闭load弹窗 load(); xhr.open( 'GET' , url, true ); // 也可用POST方式 xhr.responseType = "blob" ; xhr.onload = function () { if ( this .status === 200) { var blob = this .response; if (navigator.msSaveBlob == null ) { var a = document.createElement( 'a' ); var headerName = xhr.getResponseHeader( "Content-disposition" ); a.download = decodeURIComponent(headerName).substring(20); a.href = URL.createObjectURL(blob); $( "body" ).append(a); // 修复firefox中无法触发click a.click(); URL.revokeObjectURL(a.href); $(a).remove(); } else { navigator.msSaveBlob(blob, decodeURIComponent(headerName).substring(20)); } } disload(); }; xhr.send(); } else { window.location.href = url; } }; |
<script src="xxx/layui/layui.js"></script>
<script src="xxx/jquery.min.js"></script>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
2012-05-24 c# enum 枚举名称和ID 互换获取.................
2012-05-24 Sql : 触发器 update
2006-05-24 DataGrid的多种格式化显示方法