Horje
how to edit a fil with vanilla js Code Example
how to edit a fil with vanilla js
(function () {
    var textFile = null;
  function makeTextFile(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');
  var textbox = document.getElementById('textbox');

    //create a click event listener
  create.addEventListener('click', function () {
    var link = document.getElementById('downloadlink');
    link.setAttribute('download', 'info.txt');
    //make the text file
    link.href = makeTextFile(textbox.value);
    link.style.display = 'block';
        //wait for the link to be rendered and then initiate a click to download the file
     window.requestAnimationFrame(function () {
      var event = new MouseEvent('click');
      link.dispatchEvent(event);
      document.body.removeChild(link);
    });
  }, false);

})();




Javascript

Related
async await react stackoverflow Code Example async await react stackoverflow Code Example
js mysql date format and dmy format Code Example js mysql date format and dmy format Code Example
Node.js process.argv Code Example Node.js process.argv Code Example
carbon to moment js conversion Code Example carbon to moment js conversion Code Example
formula regex para validar cpf e cnpj no google forms Code Example formula regex para validar cpf e cnpj no google forms Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9