Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

create a text file from var js

(function () {
var textFile = null,
  makeTextFile = function (text) {
    var data = new Blob([text], {type: 'text/plain'});

    // If we are replacing a previously generated file we need to
    // manually revoke the object URL to avoid memory leaks.
    if (textFile !== null) {
      window.URL.revokeObjectURL(textFile);
    }

    textFile = window.URL.createObjectURL(data);

    return textFile;
  };


  var create = document.getElementById('create'),
    textbox = document.getElementById('textbox');

  create.addEventListener('click', function () {
    var link = document.getElementById('downloadlink');
    link.href = makeTextFile(textbox.value);
    link.style.display = 'block';
  }, false);
})();
Comment

PREVIOUS NEXT
Code Example
Javascript :: fs.writefile 
Javascript :: binary to ascii javascript 
Javascript :: get the last option from select jquery 
Javascript :: moment js day name language 
Javascript :: image border shadow react native 
Javascript :: check if element is visible jquery 
Javascript :: c# get value from json object 
Javascript :: window localtion javascript 
Javascript :: how to use ionicons in react 
Javascript :: jquery post failure 
Javascript :: jquery datepicker change date format 
Javascript :: refreshing a page with jquery 
Javascript :: validate json file programmatically in python 
Javascript :: javasscript get the content inbetween a select tag 
Javascript :: svelte mount 
Javascript :: delete parent element javascript 
Javascript :: discord.js channel regex 
Javascript :: how use for loop in append attribute in jquery 
Javascript :: flutter keep local storage even after is closed 
Javascript :: iso string to timestamp javascript 
Javascript :: javascript find all href with same value 
Javascript :: javascript canvas without html 
Javascript :: autoplay video in angular 
Javascript :: js array none 
Javascript :: adonisjs findorcreate 
Javascript :: update replit node 
Javascript :: javascript discord bot 8 ball command 
Javascript :: how to get the sum of a column in sequelize 
Javascript :: next js update 
Javascript :: js nullish 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =