![]() "description": "Reads a text file in two different ways. ![]() const Cu = Components.utils //Uncomment this line for Overlay/XUL and bootstrap add-onsĬonst ).then(text => text) Below this line will also work for Overlay/XUL and bootstrap/restartless add-ons Above this line is specific to the Firefox Add-on SDK Var buttons = require('sdk/ui/button/action') Open the Browser Console (Used in testing/developmenti to monitor errors/console)ĪctiveWin = utils.getMostRecentBrowserWindow() Ī('menu_browserConsole').doCommand() Read-text-file:readUtf8File: This is a text file line 1 The output in the console for the example text file included below is: read-text-file:readTextFile: This is a text file line 1 ![]() Promise: Handling errors and common pitfallsīelow is a complete Firefox Add-on SDK extension which twice reads and outputs to the console the file at B:\testFile.txt.Unfortunately, you have not included that information in the question. What exactly the issue is would likely be determined if you looked in the Browser Console ( Ctrl- Shift- J, or Cmd- Shift- J on OSX). The output in the console for the example text file included below is: read-text-file:readTextFile: This is a text file line 1 Line 2 read-text-file:readUtf8File: This is a text file line 1 Line 2. However, alert() will not normally be defined, unless you have defined it somewhere else in your code. Below is a complete Firefox Add-on SDK extension which twice reads and outputs to the console the file at B:testFile.txt. However, that assumes that alert() is defined and there was no error when you tried to read the file. The code you have basically works as written.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |