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 make slide js in owl carousel auto 
Javascript :: how to create react native project at specific version 
Javascript :: getters in nuxt vuex acccessing 
Javascript :: `object` ("[object Object]") cannot be serialized as JSON. Please only return JSON serializable data types 
Javascript :: detect two strings are anagram of each other in JavaScript 
Javascript :: remove trailing slash javascript 
Javascript :: how to detect clicks with javascript 
Javascript :: javascript const require 
Javascript :: jquery this 
Javascript :: blob url to base64 javascript 
Javascript :: disable strict mode angular 
Javascript :: sleep js 
Javascript :: vite install in vue 
Javascript :: committing only some changes to git 
Javascript :: toggle classname onclick react 
Javascript :: Angular Unit Testing: Observable not returning results 
Javascript :: javascript date to string format 
Javascript :: javascript multiline string 
Javascript :: how to parse json in java 
Javascript :: first day of month and last day of month moment js 
Javascript :: js cookies 
Javascript :: jquery datatable iterate all rows 
Javascript :: make select option selected javascript 
Javascript :: sequelize.org findById 
Javascript :: jquery checkbox 
Javascript :: return random rows sqlite 
Javascript :: set background opacity react native 
Javascript :: cheerio get href text 
Javascript :: javascript settimeout loop 
Javascript :: get the integer after decimal in javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =