Przykłady Javascript znalezione w wielu witrynach dla mnie nie działają

Próbuję odczytać plik tekstowy, który znajduje się w tym samym katalogu, co mój plik HTML, używając javascript, aby móc zawrzeć zawartość pliku tekstowego w moim pliku HTML.

Oto kod, który muszę przetestować funkcje fopen i fread

<html>

<head>

</head>

<body>
<script>
   fh = fopen('my.txt', 0); // Open the file for reading.
   if(fh!=-1) // Check if the file has been successfully opened.
   {
   length = flength(fh); // Get the length of the file.
   str = fread(fh, length); // Read in the entire file.
   fclose(fh); // Close the file.

   // Display the contents of the file.
   write(str);
   } 
</script>
</body>

</html>

Próbowałem zastąpić „write” poleceniem document.write i nadal nic.

Oto kilka stron internetowych, które miały ten kod jako przykład:

http://answers.yahoo.com/question/index?qid=20130519190823AA2lQ1W

http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm

Każda pomoc w ogóle byłaby mile widziana.

DZIĘKUJĘ CI!!!

questionAnswers(3)

yourAnswerToTheQuestion