Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript download string as file

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

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

  element.click();

  document.body.removeChild(element);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm json server 
Javascript :: enzyme debug 
Javascript :: check if input is valid 
Javascript :: disemvowel trolls codewars javascript 
Javascript :: react material ui media queries 
Javascript :: select tag event listener 
Javascript :: javascript interview preparation 
Javascript :: get browser timezone 
Javascript :: sequelize update record 
Javascript :: clear elements of table javascript 
Javascript :: flutter text with icon 
Javascript :: random number generator javascript 
Javascript :: Regex match word js 
Javascript :: check if array does not contain value javascript 
Javascript :: longest word javascript 
Javascript :: pass data navigate react router dom 
Javascript :: json fetch data doest show 
Javascript :: fetchData from json file 
Javascript :: printf statement in javascript 
Javascript :: check if item exists in localstorage javascript 
Javascript :: js decrement for loop 
Javascript :: js scrollintoview 
Javascript :: convert number to string date js 
Javascript :: javascript add new line in string 
Javascript :: color console 
Javascript :: number to binary javascript 
Javascript :: generate a sequence numbers between a range javascript 
Javascript :: flutter circularprogressindicator 
Javascript :: js remove query param from url 
Javascript :: nodemailer custom font 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =