A Question About FSOs !!

Discussion in 'Javascript' started by @(none), Jan 8, 2005.

  1. @(none)

    @(none) Guest

    I am trying to write a file on the server ( currently my local machine )
    using FSO, but am having problems.

    I have the following code ( which I got from several sources - mainly
    http://sislands.com/coin70/week10/asp/fsobj.htm and have inserted this
    both inside a function and outside.

    var fso;
    ForAppending = 8
    fso = new ActiveXObject( "Scripting.FileSystemObject" );
    var selects = fso_OpenTextFile(
    "/home/mas/tradeFiles/webSite/files/selections.txt", ForAppending, true,
    false );
    selects.WriteLine( "Hello" );


    Problem is as soon as it gets to the 4th line ( selects = fso...........
    ) the browser hangs. Isuspected there may be a setting in the browser
    but this doesn't seem to be the problem ( Mozilla ), now I suspect
    javascript may need some sort of include statement ( does it have such a
    concept ?? )

    Has anyone out there actually created and written to a file in
    javascript ?? The two books I have don't even make reference to file
    operations ( I know I'll get the O'Reilly book next week ;-) )

    Hope someone can help !! Thanks.
     
    @(none), Jan 8, 2005
    #1
    1. Advertising

  2. @(none)

    Randy Webb Guest

    none wrote:

    > I am trying to write a file on the server ( currently my local machine )
    > using FSO, but am having problems.


    FSO has no access to write to the server. It can only write to the Hard
    Drive.

    > I have the following code ( which I got from several sources - mainly
    > http://sislands.com/coin70/week10/asp/fsobj.htm and have inserted this
    > both inside a function and outside.
    >
    > var fso;
    > ForAppending = 8
    > fso = new ActiveXObject( "Scripting.FileSystemObject" );


    Did the website tell you that Mozilla doesn't support ActiveXObject or
    does it tell you to check Mozilla's JS Console? Tools>Web
    Development>Javascript Console.


    > var selects = fso_OpenTextFile(
    > "/home/mas/tradeFiles/webSite/files/selections.txt", ForAppending, true,
    > false );
    > selects.WriteLine( "Hello" );


    Mozilla reports the following:

    Error: ActiveXObject is not defined
    Source File:
    file:///C:/Documents%20and%20Settings/Randy/My%20Documents/test4.html
    Line: 12

    >
    > Problem is as soon as it gets to the 4th line ( selects = fso...........
    > ) the browser hangs. Isuspected there may be a setting in the browser
    > but this doesn't seem to be the problem ( Mozilla ), now I suspect
    > javascript may need some sort of include statement ( does it have such a
    > concept ?? )


    Yes. <script src="someFile.js"....> But it's irrelevant to your problem.

    > Has anyone out there actually created and written to a file in
    > javascript ??


    Yes, you can't do it in Mozilla though. Its an IE-only item.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Randy Webb, Jan 8, 2005
    #2
    1. Advertising

  3. @(none)

    @(none) Guest

    Randy Webb wrote:
    > none wrote:
    >
    >> I am trying to write a file on the server ( currently my local machine
    >> ) using FSO, but am having problems.

    >
    >
    > FSO has no access to write to the server. It can only write to the Hard
    > Drive.
    >
    >> I have the following code ( which I got from several sources - mainly
    >> http://sislands.com/coin70/week10/asp/fsobj.htm and have inserted this
    >> both inside a function and outside.
    >>
    >> var fso;
    >> ForAppending = 8
    >> fso = new ActiveXObject( "Scripting.FileSystemObject" );

    >
    >
    > Did the website tell you that Mozilla doesn't support ActiveXObject or
    > does it tell you to check Mozilla's JS Console? Tools>Web
    > Development>Javascript Console.
    >
    >


    No but I had my doubts !!
    >> var selects = fso_OpenTextFile(
    >> "/home/mas/tradeFiles/webSite/files/selections.txt", ForAppending,
    >> true, false );
    >> selects.WriteLine( "Hello" );

    >
    >
    > Mozilla reports the following:
    >
    > Error: ActiveXObject is not defined
    > Source File:
    > file:///C:/Documents%20and%20Settings/Randy/My%20Documents/test4.html
    > Line: 12
    >


    Mine just hangs !!
    >>
    >> Problem is as soon as it gets to the 4th line ( selects =
    >> fso........... ) the browser hangs. Isuspected there may be a setting
    >> in the browser but this doesn't seem to be the problem ( Mozilla ),
    >> now I suspect javascript may need some sort of include statement (
    >> does it have such a concept ?? )

    >
    >
    > Yes. <script src="someFile.js"....> But it's irrelevant to your problem.
    >
    >> Has anyone out there actually created and written to a file in
    >> javascript ??

    >
    >
    > Yes, you can't do it in Mozilla though. Its an IE-only item.
    >

    No there was nothing in any of the stuff about it being IE specific (
    ActiceX ) but I did gather that JS was not file friendly o. Bit of a
    bugger really but I suppose I can see the sense behind it.

    Thanks for the answer !!
     
    @(none), Jan 8, 2005
    #3
  4. @(none)

    Robert Guest

    In article <41df464f$0$5383$>,
    "@(none)" <""mas\"@(none)"> wrote:


    > Has anyone out there actually created and written to a file in
    > javascript ?? The two books I have don't even make reference to file
    > operations ( I know I'll get the O'Reilly book next week ;-) )


    And you like to read the password file?

    http://www.jibbering.com/faq/#FAQ4_3

    4.3 How can I access the client-side filesystem?

    Security means that by default you can't. In a more restricted
    enviroment, there are options (e.g. live connect to Java in NN, and
    using FileSystemObject in IE) check http://groups.google.com/ for
    previous posts on the subject.
    http://msdn.microsoft.com/library/en-us/script56/html/jsobjFileSystem.asp
    http://www.javaworld.com/javaworld/jw-10-1998/jw-10-apptowin32.html

    Robert
     
    Robert, Jan 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    628
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    697
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    975
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    447
    Philip Meyer
    Nov 30, 2003
  5. Bit Byte
    Replies:
    1
    Views:
    882
    Teemu Keiski
    Jan 28, 2007
Loading...

Share This Page