Answers for "read from file javascript in html"

2

how to open html file with javascript

// In my case, I used a button to activate this function:
function myFunction() {
    window.location.href = 'index.html';
}
Posted by: Guest on November-18-2020
0

javascript read file

<!DOCTYPE html>
<html>
  
<head>
    <title>Read Text File</title>
</head>
  
<body>
    <input type="file" name="inputfile"
            id="inputfile">
    <br>
   
    <pre id="output"></pre>
      
    <script type="text/javascript">
        document.getElementById('inputfile')
            .addEventListener('change', function() {
              
            var fr=new FileReader();
            fr.onload=function(){
                document.getElementById('output')
                        .textContent=fr.result;
            }
              
            fr.readAsText(this.files[0]);
        })
    </script>
</body>
  
</html>
Posted by: Guest on March-06-2022

Code answers related to "read from file javascript in html"

Code answers related to "Javascript"

Browse Popular Code Answers by Language