I am working on thymeleaf and in my code i have a download button which triggers the javascript function. The button is working well on chrome but not on Internet Explorer.
Javascript code:
function Download(containerid) {
var fileName = 'tags.txt';
var elHtml = document.getElementById(containerid).innerHTML;
var link = document.createElement('a');
mimeType = 'text/html' || 'text/plain';
link.setAttribute('download', 'ApiResponse.txt');
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
link.click();
}
HTML from where it is being called:
<div class="tooltipp">
<img onclick="Download('responseMessageEndpoint')"
style="width: 20px; height: 20px;" th:src="@{css/download.jpg}" />
<span class="tooltiptextt">Download</span>
</div>
From what i have googled, download.createElement('a')
is not being supported by IE. But i am not able to fine a good workaround.
Thanks in advance!