How to read and display file in a chrome extension

A better option would be to store the contents of your text in your HTML itself using something like

<script id="textFile" type="text/x-template">...</script>

and then reference the contents of the template via document.getElementById('textFile').

Let me know if you need more information.


Use XMLHttpRequest.

Example:

var xhr = new XMLHttpRequest();
xhr.open('GET', chrome.extension.getURL('script1.txt'), true);
xhr.onreadystatechange = function()
{
    if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200)
    {
        //... The content has been read in xhr.responseText
    }
};
xhr.send();