Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript download json

function download(filename, json){
    const element = document.createElement('a');
    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(json)));
    element.setAttribute('download', filename);

    element.style.display = 'none';
    document.body.appendChild(element);

    element.click();

    document.body.removeChild(element);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: firebase auth sign out javascript 
Javascript :: laravel 8 include javascript in blade 
Javascript :: page redirect after a few seconds 
Javascript :: axios file upload 
Javascript :: expo update react native 
Javascript :: trigger event javascript 
Javascript :: once content is loaded run function 
Javascript :: google maps js on map load 
Javascript :: string to JSONobject android 
Javascript :: visual studio code cursor color 
Javascript :: regex cnpj javascript 
Javascript :: document ready javacsript 
Javascript :: regex valid jwt 
Javascript :: jquery set max attribute value 
Javascript :: min max and average finder in js array 
Javascript :: word count js 
Javascript :: how to filter an array to only get numbers 
Javascript :: javascript replace <br with n 
Javascript :: javascript degree to radians 
Javascript :: Writing files in Node.js 
Javascript :: js remove after character 
Javascript :: scrollto element by id center 
Javascript :: npm update react 
Javascript :: angular date formats 
Javascript :: javascript get hostname from current url 
Javascript :: delete parent element javascript 
Javascript :: Material App debug mode 
Javascript :: get all iinputs of type button 
Javascript :: scroll to class jquery 
Javascript :: js add click listener 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =