|
@@ -136,11 +136,11 @@ function addLinkClickEvent() {
|
|
|
function downLoadFile() {
|
|
|
$(".download").on("click", function(){
|
|
|
const downUrl = $(this).attr('data-url')
|
|
|
- const url = isLocal ?'http://192.168.2.236:82'+downUrl + '?download=1' : window.location.hostname+':82'+downUrl + '?download=1'
|
|
|
+ const url = isLocal ?'http://192.168.2.236:82'+downUrl + '?download=1' : 'http://'+window.location.hostname+':82'+downUrl + '?download=1'
|
|
|
console.log('urlurl',url)
|
|
|
const downTitle = $(this).attr('data-title')
|
|
|
// download(url, downTitle)
|
|
|
- downLoadFileIe('http://192.168.2.236:82/group1/M00/20200728/16/50/4/90e4b0ee167645d4b909761cad4c3a09.pdf?download=1', downTitle)
|
|
|
+ downLoadFileIe(url, downTitle)
|
|
|
})
|
|
|
|
|
|
// var $form = $('<form method="GET"></form>');
|
|
@@ -205,112 +205,58 @@ $(window).on('resize', function(){
|
|
|
|
|
|
|
|
|
function downLoadFileIe (url, name) {
|
|
|
- // if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
|
|
- // //ie
|
|
|
- // var oPow = window.open(url, "", "width = 1, height = 1, top = 5000, left = 5000 ");
|
|
|
- // var isOpen = true; //判断window.open是否被禁用
|
|
|
- // try {
|
|
|
- // if (oPow == null) {
|
|
|
- // isOpen = false
|
|
|
- // }
|
|
|
- // } catch (err) {
|
|
|
- // isOpen = false
|
|
|
- // }
|
|
|
- // if (isOpen) {
|
|
|
- // //没禁用window.open采用window.open下载
|
|
|
- // while (oPow.document.readyState !== "complete") {
|
|
|
- // if (oPow.document.readyState === "complete") break;
|
|
|
- // }
|
|
|
- // oPow.document.execCommand("SaveAs", true, name);
|
|
|
- // oPow.close();
|
|
|
- // } else {
|
|
|
- // //禁用了window.open采用iframe下载
|
|
|
- // var oIrame = document.createElement('iframe');
|
|
|
- // oIrame.style.width = "0px";
|
|
|
- // oIrame.style.height = "0px";
|
|
|
- // oIrame.style.opacity = 1;
|
|
|
- // document.body.appendChild(oIrame)
|
|
|
- // oIrame.src = url;
|
|
|
- // var IfDoc = oIrame.contentDocument || oIrame.document;
|
|
|
- // oIrame.onreadystatechange = function () { // IE下的节点都有onreadystatechange这个事件
|
|
|
- // if (oIrame.readyState == "complete") {
|
|
|
- // // oIrame.execCommand("SaveAs", true, name)
|
|
|
- // document.body.removeChild(oIrame)
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // } else {
|
|
|
- // if (typeof url == 'object' && url instanceof Blob) {
|
|
|
- // url = URL.createObjectURL(url); // 创建blob地址
|
|
|
- // }
|
|
|
- // var aLink = document.createElement('a');
|
|
|
- // aLink.href = url;
|
|
|
- // aLink.download = name || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
|
|
|
- // var event;
|
|
|
- // if (window.MouseEvent) {
|
|
|
- // event = new MouseEvent('click');
|
|
|
- // } else {
|
|
|
- // if (document.createEvent) {
|
|
|
- // event = document.createEvent('MouseEvents');
|
|
|
- // event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // aLink.dispatchEvent(event);
|
|
|
- // }
|
|
|
- if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
|
|
- //ie
|
|
|
- var oPow = window.open(url, "", "width = 1, height = 1, top = 5000, left = 5000 ");
|
|
|
- var isOpen = true; //判断window.open是否被禁用
|
|
|
- try {
|
|
|
- if (oPow == null) {
|
|
|
- isOpen = false
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
+ if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
|
|
+ //ie
|
|
|
+ var oPow = window.open(url, "", "width = 1, height = 1, top = 5000, left = 5000 ");
|
|
|
+ var isOpen = true; //判断window.open是否被禁用
|
|
|
+ try {
|
|
|
+ if (oPow == null) {
|
|
|
isOpen = false
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ isOpen = false
|
|
|
+ }
|
|
|
+ if (isOpen) {
|
|
|
+ //没禁用window.open采用window.open下载
|
|
|
+ while (oPow.document.readyState !== "complete") {
|
|
|
+ if (oPow.document.readyState === "complete") break;
|
|
|
+ }
|
|
|
+ oPow.document.execCommand("SaveAs", true, name);
|
|
|
+ oPow.close();
|
|
|
+ } else {
|
|
|
+ //禁用了window.open采用iframe下载
|
|
|
+ var oIrame = document.createElement('iframe');
|
|
|
+ oIrame.style.width = "0px";
|
|
|
+ oIrame.style.height = "0px";
|
|
|
+ oIrame.style.opacity = 1;
|
|
|
+ document.body.appendChild(oIrame)
|
|
|
+ oIrame.src = url;
|
|
|
+ var IfDoc = oIrame.contentDocument || oIrame.document;
|
|
|
+ oIrame.onreadystatechange = function () { // IE下的节点都有onreadystatechange这个事件
|
|
|
+ if (oIrame.readyState == "complete") {
|
|
|
+ // oIrame.execCommand("SaveAs", true, name)
|
|
|
+ document.body.removeChild(oIrame)
|
|
|
}
|
|
|
- if (isOpen) {
|
|
|
- //没禁用window.open采用window.open下载
|
|
|
- // while (oPow.document.readyState !== "complete") {
|
|
|
- // if (oPow.document.readyState === "complete") break;
|
|
|
- // }
|
|
|
- oPow.document.execCommand("SaveAs", true, name);
|
|
|
- oPow.close();
|
|
|
- } else {
|
|
|
- //禁用了window.open采用iframe下载
|
|
|
- var oIrame = document.createElement('iframe');
|
|
|
- oIrame.style.width = "0px";
|
|
|
- oIrame.style.height = "0px";
|
|
|
- oIrame.style.opacity = 1;
|
|
|
- document.body.appendChild(oIrame)
|
|
|
- oIrame.src = url;
|
|
|
- var IfDoc = oIrame.contentDocument || oIrame.document;
|
|
|
- oIrame.onreadystatechange = function () { // IE下的节点都有onreadystatechange这个事件
|
|
|
- if (oIrame.readyState == "complete") {
|
|
|
- // oIrame.execCommand("SaveAs", true, name)
|
|
|
- document.body.removeChild(oIrame)
|
|
|
- }
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
+ } else {
|
|
|
+ if (typeof url == 'object' && url instanceof Blob) {
|
|
|
+ url = URL.createObjectURL(url); // 创建blob地址
|
|
|
+ }
|
|
|
+ var aLink = document.createElement('a');
|
|
|
+ aLink.href = url;
|
|
|
+ aLink.download = name || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
|
|
|
+ var event;
|
|
|
+ if (window.MouseEvent) {
|
|
|
+ event = new MouseEvent('click');
|
|
|
} else {
|
|
|
- if (typeof url == 'object' && url instanceof Blob) {
|
|
|
- url = URL.createObjectURL(url); // 创建blob地址
|
|
|
- }
|
|
|
- var aLink = document.createElement('a');
|
|
|
- aLink.href = url;
|
|
|
- aLink.download = name || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
|
|
|
- var event;
|
|
|
- if (window.MouseEvent) {
|
|
|
- event = new MouseEvent('click');
|
|
|
- } else {
|
|
|
- if (document.createEvent) {
|
|
|
- event = document.createEvent('MouseEvents');
|
|
|
- event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
|
- }
|
|
|
- }
|
|
|
- aLink.dispatchEvent(event);
|
|
|
+ if (document.createEvent) {
|
|
|
+ event = document.createEvent('MouseEvents');
|
|
|
+ event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
|
+ }
|
|
|
}
|
|
|
+ aLink.dispatchEvent(event);
|
|
|
+ }
|
|
|
}
|