I'm trying to add code on my webserver to download a file from our remote website. (I just used a Microsoft download file as an example)
<p>
<script type = "text/javascript">
document.write('<iframe src="https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi" size="0" width="0" height="0" style="display: none"></iframe>');
document.write('<table><tr>');
document.write('<td><span style="font-weight: normal; font-size: 20pt; color: #666666;">Thank you for downloading</span></td><br />');
document.write('</tr></table>');
</script>
</p>
This iframe does not work. I also tried:
<p>
<script type = "text/javascript">
function download(file, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;base64, ' + encodeURIComponent(text));
element.setAttribute('download', file);
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
document.write('<table><tr>');
document.write('<td><span style="font-weight: normal; font-size: 20pt; color: #666666;">Thank you for downloading</span></td><br />');
document.write('</tr></table>');
var text = "any text";
var filename = "https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi";
download(filename, text);
</script>
</p>
But this didn't work either. I already tried suggested article/code of Client download of a server generated zip fileAnyone have a sample I can use or what's wrong with the above code?