Reading contents of a text file using JavaScript throwing error
- by vix
I'm using the following code to read the content of a text file using javascript. But when I'm getting an alert message which says "An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?" When I click on yes nothing is happening.
I'm using IE 6.0
function ieReadFile(filename)
{
try
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.OpenTextFile(filename,1);
var contents = fh.ReadAll();
fh.Close();
alert(contents);
//return contents;
}
catch (Exception)
{
return "Cannot open file :(";
}
}
Can anyone please help me resolve this issue?