I was looking for a way to write to a file in javascript.I found excatly what I was looking for here
but the problem is that it uses jquery.I am suppose to do this task with pure javascript.
My question is how would I convert a $ sign to a pure javascript without including the jquery script in the code.
In short how would I convert this code to pure javascript if its possible.
function createDownloadLink(anchorSelector, str, fileName){
if(window.navigator.msSaveOrOpenBlob) {
var fileData = [str];
blobObject = new Blob(fileData);
$(anchorSelector).click(function(){
window.navigator.msSaveOrOpenBlob(blobObject, fileName);
});
} else {
var url = "data:text/plain;charset=utf-8," + encodeURIComponent(str);
$(anchorSelector).attr("download", fileName); //when I try document,getElementById it does not work.
$(anchorSelector).attr("href", url);
}
}
$(function () {
var str = "kgopelo is my name in the place";
createDownloadLink("#export",str,"file.txt");
});
Thanks in advanced.