Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js save files

//javascript
function download(text, name, type) {
  var a = document.getElementById("a");
  var file = new Blob([text], {type: type});
  a.href = URL.createObjectURL(file);
  a.download = name;
}
//html
<a href="" id="a">click here to download your file</a>
<button onclick="download('file text', 'myfilename.txt', 'text/plain')">Create file</button>
Comment

save file javascript

// Function to download data to a file
function download(data, filename, type) {
    var file = new Blob([data], {type: type});
    if (window.navigator.msSaveOrOpenBlob) // IE10+
        window.navigator.msSaveOrOpenBlob(file, filename);
    else { // Others
        var a = document.createElement("a"),
                url = URL.createObjectURL(file);
        a.href = url;
        a.download = filename;
        document.body.appendChild(a);
        a.click();
        setTimeout(function() {
            document.body.removeChild(a);
            window.URL.revokeObjectURL(url);  
        }, 0); 
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to sum the array values in javascript 
Javascript :: ordenar un array de mayor a menor 
Javascript :: sequelize transaction util 
Javascript :: functional component react 
Javascript :: === javascript 
Javascript :: js regex find 
Javascript :: new date 
Javascript :: javascript boolean 
Javascript :: dispay react component after some time 
Javascript :: react redux not updating 
Javascript :: how to append data to a form data in javascript 
Javascript :: jquery bootstrap checkbox val 
Javascript :: push javascript 
Javascript :: JavaScript setTimeout js function timer 
Javascript :: loading react 
Javascript :: sweetalert js full code 
Javascript :: jquery get all data attributes values 
Javascript :: async promise javascript 
Javascript :: form an array from i to j javascript 
Javascript :: bind jquery 
Javascript :: Error: Node Sass version 5.0.0 is incompatible with ^4.0.0 
Javascript :: generate qr code react 
Javascript :: how to check characters inside a string javascript 
Javascript :: discord.js buttons 
Javascript :: afficher une variable dans la console javascript 
Javascript :: javascript name convention 
Javascript :: mongodb mapreduce 
Javascript :: sequelize get data 
Javascript :: from json timestamp to date python 
Javascript :: URLSearchParams for query params 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =