I am trying to load one HTML file into another.
index.html
<!DOCTYPE html>
<html>
    <body>
        <div id="default"></div>
        <script src="index.js"></script>
    </body>
</html>
I found this js code to use, but instead of using a button click I want the file to be read and passed to innerHTML onload
index.js
window.onload = function() {
        var fileInput = document.getElementById('fileInput');
        var fileDisplayArea = document.getElementById('fileDisplayArea');
        fileInput.addEventListener('change', function(e) {
            var file = fileInput.files[0];
            var textType = /text.*/;
            if (file.type.match(textType)) {
                var reader = new FileReader();
                reader.onload = function(e) {
                    fileDisplayArea.innerText = reader.result;
                }
                reader.readAsText(file);    
            } else {
                fileDisplayArea.innerText = "File not supported!"
            }
        });
}
Thanks, also is window.onload = function() necessary here?
 
     
    