I'm trying to make a simple page with JS which generates Batch Scrips based on user input. This is the prototype code and works fine with Chrome, but clicking on link with Firefox downloads the file as .txt (e.g.: file.bat.txt) and IE is completey unresponsive to the link Where am i going wrong? Any issues with "data:text/plain;base64,"?
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>
<body>
<a href="#" download="file.bat">click here</a>
<script>
var bat_source = "@echo off\necho Hello world\npause";
document.querySelector("a").href = 'data:text/plain;base64,' + btoa(bat_source);
</script>
</body>
</html>