Created
April 27, 2016 06:07
-
-
Save asith-w/47fdd82846abb91146bf24a6fa9df021 to your computer and use it in GitHub Desktop.
forceToDownload.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var link = $("<a />"); | |
link.appendTo("body"); | |
link.attr("id", "csvDwnLink"); | |
window.URL = window.URL || window.webkitURL; | |
var csv = "\ufeff" + "col1;col2;col3", | |
blob = new window.Blob([csv], {type: 'text/csv, charset=UTF-8'}), | |
csvUrl = window.URL.createObjectURL(blob), | |
filename = 'export.csv'; | |
link.attr({'download': filename, 'href': csvUrl, 'target': '_blank'}); | |
$(link)[0].click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment