Skip to content

Commit b3a077c

Browse files
committed
Microsoft Internet Explorer adaptation for Download File window for GetTemplate button. Now it works to download template in MS Internet Explorer web-browser.
1 parent 0b09e83 commit b3a077c

File tree

1 file changed

+26
-3
lines changed
  • src/main/resources/static/js

1 file changed

+26
-3
lines changed

src/main/resources/static/js/main.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,22 @@ jQuery(document).ready(function() {
416416
event.stopPropagation();
417417
event.preventDefault();
418418

419+
// Special handling for MS Explorer Download file window
420+
function createDownloadWindowMSExplorer(filename, url) {
421+
422+
var blob = null;
423+
var xhr = new XMLHttpRequest();
424+
xhr.open("GET", url);
425+
xhr.responseType = "blob";
426+
xhr.onload = function()
427+
{
428+
blob = xhr.response;
429+
window.navigator.msSaveBlob(blob, filename);
430+
}
431+
xhr.send();
432+
}
433+
434+
// HTML5 Download File window handling
419435
function createDownloadWindow(filename, url) {
420436
var pom = document.createElement('a');
421437
pom.setAttribute('href', url);
@@ -430,9 +446,16 @@ jQuery(document).ready(function() {
430446
pom.click();
431447
}
432448
}
433-
434-
createDownloadWindow("SubscriptionsTemplate.json","\/download\/subscriptiontemplate");
435-
449+
450+
// If MS Internet Explorer -> special handling for creating download file window.
451+
if (window.navigator.msSaveBlob) {
452+
createDownloadWindowMSExplorer("SubscriptionsTemplate.json", "/download/subscriptiontemplate");
453+
454+
}
455+
else {
456+
// HTML5 Download File window handling
457+
createDownloadWindow("SubscriptionsTemplate.json","\/download\/subscriptiontemplate");
458+
}
436459
});
437460
// /END ## get_subscription_template #################################################
438461

0 commit comments

Comments
 (0)