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 :: javascript check empty object 
Javascript :: how to change the background color in jquery 
Javascript :: popper.js install npm 
Javascript :: local storage check max size 
Javascript :: fs write stream append 
Javascript :: javascript hasownproperty 
Javascript :: error: Error: Unable to resolve module `react-native-gesture-handler` from `node_modules@react-navigation ativelibmoduleScrollables.js`: react-native-gesture-handler could not be found within the project. 
Javascript :: How to remove text from a string in javscript 
Javascript :: javascript react reverse map 
Javascript :: javascript loop through all element children 
Javascript :: Jquery Scroll on div using anchor tag is not Working properly 
Javascript :: localstorage read all key 
Javascript :: createdAt 
Javascript :: update cypress 
Javascript :: javascript friendly number format with commas 
Javascript :: react native navigation reset history 
Javascript :: multer save file with extension 
Javascript :: fullscreen mode javascript 
Javascript :: foreach selector in jquery 
Javascript :: javascript sorting array string by len 
Javascript :: slick slider infinite loop 
Javascript :: postman alternative 
Javascript :: alert ok with link 
Javascript :: react native center text vertically full screen 
Javascript :: mm dd yyyy how to get date in this format in javascript 
Javascript :: get time from a date time in jquery 
Javascript :: js touch relative pos 
Javascript :: clean up async requests in react useEffect hook using abort controller 
Javascript :: htaccess to deploy react app to cpanel 
Javascript :: jquery to set value in select2 dropdown button 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =