Skip to content

Instantly share code, notes, and snippets.

@joshmcarthur
Created February 13, 2019 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmcarthur/114357808ff67a8729f3857ac18d3e6d to your computer and use it in GitHub Desktop.
Save joshmcarthur/114357808ff67a8729f3857ac18d3e6d to your computer and use it in GitHub Desktop.
IE9 Download Example
<html>
<head>
<title>IE9 Download Example</title>
<script>
function legacyBrowserSave(content, filename) {
var frame = document.createElement("iframe");
document.body.appendChild(frame);
frame.contentWindow.document.open("text/html", "replace");
frame.contentWindow.document.write(content);
frame.contentWindow.document.close();
frame.contentWindow.focus();
frame.contentWindow.document.execCommand("SaveAs", true, filename);
document.body.removeChild(frame);
return false;
}
</script>
<body>
<button onClick="legacyBrowserSave('this,is,csv,content', 'example.csv')">Save file (<IE10 only)</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment