Answers for "how to open javascript file"

1

javascript how to open a file

function readSingleFile(e) {
  var file = e.target.files[0];
  if (!file) {
    return;
  }
  var reader = new FileReader();
  reader.onload = function(e) {
    var contents = e.target.result;
    displayContents(contents);
  };
  reader.readAsText(file);
}

function displayContents(contents) {
  var element = document.getElementById('file-content');
  element.textContent = contents;
}

document.getElementById('file-input')
  .addEventListener('change', readSingleFile, false);
Posted by: Guest on June-08-2020
-1

javascript how to open a file

window.open("file:///D:/Hello.txt");
Posted by: Guest on June-08-2020
0

how to open javascript file

// you can open JavaScript files (.js) in any text editor
Posted by: Guest on May-31-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language