I want to read and display the contents of file in a chrome extension (The file is already inside the extension directory).How do it?Whether I can use HTML5 to read it?
var elema3 = document.body.getElementsByClassName("slicefooter");
elema3[0].innerHTML='Shanmuga Subramanian';
var a1=chrome.extension.getURL('script1.txt');
var reader = new FileReader();
reader.readAsText(a1);
Often, it is desirable for a Chrome extension to be bundled with files that need to be read. These files may contain data or configuration information to help the extension function. This short guide will show you how you can set up your Chrome extension to read files.
On your computer, open Chrome . At the top right, click Extensions .
Search Google → Chrome Web Store → Read Aloud or visit this link: Chrome Extension Reader 2. Select “Add to Chrome” button next to the “Read Aloud” option. 3. A pop-up box will appear - select the “Add extension” button.
'Text Reader' is a chrome extension that Reads for you, texts you select from websites you visit. It also have an editing window where you can type your own words/sentences to be read out loud or even upload a text document to the window or use your mic to type.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With