Solution 1:
downloadURL(data.printPDFURL, basename(data.printPDFURL));
function basename(path) {
return path.split(/[\\/]/).pop();
}
function downloadURL(url, name) {
var link = document.createElement('a');
link.download = name;
link.href = url;
link.click();
}
Solution 2:
window.open(data.printPDFURL, '_blank');
Solution 3:
window.location = data.printPDFURL;
Solution 4:
$('<iframe>').attr('src', downloadThing.attr('href')).appendTo('body').load(function() {
$(this).remove();
});
Reference:
http://stackoverflow.com/questions/3820381/need-a-basename-function-in-javascript
http://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery
http://pixelscommander.com/en/javascript/javascript-file-download-ignore-content-type/
No comments:
Post a Comment