By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,473 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,473 IT Pros & Developers. It's quick & easy.

A Question About FSOs !!

P: n/a
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.

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Jul 23 '05 #2

P: n/a
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 !!
Jul 23 '05 #3

P: n/a
In article <41**********************@news.optusnet.com.au>,
"@(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...FileSystem.asp
http://www.javaworld.com/javaworld/j...pptowin32.html

Robert
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.