Avatar of bobby122
bobby122 asked on

write on file in javascript

i am using the following function to write the time difference on file.. the problem is when i run the program on my computer, it doesn't give me any error, but as soon as i run it on the server, it gives me an error.. can anyone of you either change the following code or give me a new code to write a file in javascript..

Thanks


function WriteToFile()

      {
      
      var filename = "calculatedTime.txt";
      var fso = new ActiveXObject("Scripting.FileSystemObject");

      if (fso.FileExists(filename))
             {
             var a, ForAppending, file;
             ForAppending = 8;    
             
             file = fso.OpenTextFile(filename, ForAppending, false);
            
             file.WriteLine(time_object.this_time_difference+"\n");
            
              }

            else
                  {

                  var file = fso.CreateTextFile(filename, true);
                  file.WriteLine("Total Time in secs.\n");      
                  file.WriteLine("\n\n"+time_object.this_time_difference+"\n" );
                  
                  }
                  file.Close();


      }
JavaScript

Avatar of undefined
Last Comment
jaysolomon

8/22/2022 - Mon
bovineaux

What error?
awais99

there is no alert message... just that it isn't writing the file and an error message comes in the status bar "error on page"
ASKER
bobby122

yes awais u are right
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Saqib Khan

what is time_object.this_time_difference?
ASKER CERTIFIED SOLUTION
Saqib Khan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Saqib Khan

I assume bobby122 is dealing with "ASP". instead of using vbScript bobby122 is using jScript as Client side Language.
to run Server side pages this is underStood that Pages needs to be saved under the Web Server Root/Virtual Directory.
Now your Host Supports Asp Hosting?
jaysolomon

No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: adilkhan {http:#9178643} & amit_g {http:#9179193}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.