diff --git a/dist/download.min.js b/dist/download.min.js index 6ea4f11..38046d3 100644 --- a/dist/download.min.js +++ b/dist/download.min.js @@ -1,4 +1,4 @@ /*! DownloadJS v0.5.2 Denis Radin aka PixelsCommander Article about: http://pixelscommander.com/javascript/javascript-file-download-ignore-content-type/*/ -window.downloadFile=function(a){if(/(iP)/g.test(navigator.userAgent))return alert("Your device does not support files downloading. Please try again in desktop browser."),!1;if(window.downloadFile.isChrome||window.downloadFile.isSafari){var b=document.createElement("a");if(b.href=a,void 0!==b.download){var c=a.substring(a.lastIndexOf("/")+1,a.length);b.download=c}if(document.createEvent){var d=document.createEvent("MouseEvents");return d.initEvent("click",!0,!0),b.dispatchEvent(d),!0}}return-1===a.indexOf("?")&&(a+="?download"),window.open(a,"_self"),!0},window.downloadFile.isChrome=navigator.userAgent.toLowerCase().indexOf("chrome")>-1,window.downloadFile.isSafari=navigator.userAgent.toLowerCase().indexOf("safari")>-1; \ No newline at end of file +window.downloadFile=function(a){if(/(iP)/g.test(navigator.userAgent))return alert("Your device does not support files downloading. Please try again in desktop browser."),!1;if(window.downloadFile.isChrome||window.downloadFile.isSafari){var b=document.createElement("a");if(b.target="_blank",b.href=a,void 0!==b.download){var c=a.substring(a.lastIndexOf("/")+1,a.length);b.download=c}if(document.createEvent){var d=document.createEvent("MouseEvents");return d.initEvent("click",!0,!0),b.dispatchEvent(d),!0}}return-1===a.indexOf("?")&&(a+="?download"),window.open(a,"_blank"),!0},window.downloadFile.isChrome=navigator.userAgent.toLowerCase().indexOf("chrome")>-1,window.downloadFile.isSafari=navigator.userAgent.toLowerCase().indexOf("safari")>-1; \ No newline at end of file diff --git a/src/download.js b/src/download.js index b4659c2..20ed0c2 100644 --- a/src/download.js +++ b/src/download.js @@ -10,6 +10,7 @@ window.downloadFile = function (sUrl) { if (window.downloadFile.isChrome || window.downloadFile.isSafari) { //Creating new link node. var link = document.createElement('a'); + link.target="_blank"; link.href = sUrl; if (link.download !== undefined) { @@ -32,7 +33,7 @@ window.downloadFile = function (sUrl) { sUrl += '?download'; } - window.open(sUrl, '_self'); + window.open(sUrl, '_blank'); return true; }