I've made an empty mynote.txt in the same directory,
and open the following code with Internet Explorer,
and allow to write on hard disk (when IE asked)
but nothing in the text file: mynote.txt after the run.
what is the problem?

<html>
<body>
       
<script type="text/javascript">
       
function WriteFile()
{
  var fh = fopen("\\mynote.txt", 3);
    
  if(fh!=-1)
  {
    var str = "Some text goes here...";
    fwrite(fh, str);
    fclose(fh);
  }
}

WriteFile();

</script>

</body>
</html>

As far as I know you can't write to a file in this method from within a web page. You need to create an ActiveXObject File System Object in order to access the local file system. This will also only be available in IE as other browsers don't allow access to the FS via web code (rightfully imho) due to security concerns.

function WriteFile()
{
  var fso = new ActiveXObject("Scripting.FileSystemObject");
  var ots=fso.OpenTextFile("c:\\mynote.txt",2,true);
  
  var str = "Some text goes here...";
  ots.Write(str);
  ots.Close();
  ots=null;
  fso=null;
}
WriteFile();

I used IE for opening the javascript, as I mentioned.

Did you use the ActiveXObject and did it work?

I dont know. Wht is it? And how can I check? Its a software?

It's the example code I provided in my previous posting....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.