Hi All,
How to read a text file in JavaScript?
following code is working fine for me
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tempFile = fso.OpenTextFile(fname, 1);
var line = tempFile.ReadLine();
but it is showing a security message that
An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?
[Yes] [No]
Following code is also not working
var text = '';
var filechar;
netscape.security.PrivilegeManager.enablePrivilege('UniversalFileAccess');
var file = new java.io.File(fname);
var FileReader = new java.io.FileReader(file);
filechar = FileReader.read();
while (filechar != -1) {
text = text + String.fromCharCode(filechar);
filechar = FileReader.read();
}
FileReader.close();
alert(text);
it is showing following error on line number 3.
Microsoft JScript runtime error: 'netscape' is undefined
Can anyone has a working solution without any problem?
Thanks in advance
-Amol