Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js json download

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 :: how to check if object is empty javascript 
Javascript :: jquery wrap inner text 
Javascript :: javascript remoev css class 
Javascript :: javascript custom events with data 
Javascript :: rails routes default format json 
Javascript :: modify root in javascript 
Javascript :: run function once domcontentloaded javascript 
Javascript :: axios try catch get error status cocxe 
Javascript :: split by whitespace javascript 
Javascript :: jest setImmediate is not defined 
Javascript :: js delete element by id 
Javascript :: regular expression for indian mobile number 
Javascript :: updatedAt 
Javascript :: round to nearest hundredth javascript 
Javascript :: laravel variable in javascript 
Javascript :: get h1 text javascript 
Javascript :: get the current date time in javascript in 12 hour format 
Javascript :: is(:checked 
Javascript :: jquery url change 
Javascript :: cypress enter 
Javascript :: jquery select change get selected value 
Javascript :: js stop scrolling event 
Javascript :: fetch in js 
Javascript :: add font awesome to vue 
Javascript :: javascript generate random hex 
Javascript :: can we use two versions of jquery in same page 
Javascript :: javascript eliminar items repetidos 
Javascript :: queryselector with ul and not selecting particular li with id 
Javascript :: Javascript case insensitive string comparison 
Javascript :: javascript date 3 months ago 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =