473,625 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript and write to text file

Hi,
I understand that for security and other reasons that javascript does
not support writing/reading
to text files. I am looking for a way that will however.
This is what i am trying to do. I want to develop a simple html page
that is run locally on a windows
2000 box in IE. The page will have a browse button to select a source
folder, either locally or a network
computer on same lan. A destination folder, either locally or a network
computer on same lan
These two paths will be written to a text file.
Then the page has two fields, A and B. Both A and B have their own
'Add' Buttons. So I would
enter a number into either field A or B and hit add.
Then the whole form has a Reset and Submit Button. So once I was done
entering all the data into
all fields, I would hit submit and create a text file from it.
I made this quickly to give an idea
http://www.largeprojections.com/js/page1.htm

One thing i would like to do is display all the data I have entered,
so once I select the Source folder,
it displays on the page. Likewise with the data in Fields A and B once
I add it.
So the page may look like this
http://www.largeprojections.com/js/page2.htm
It wouldn't have to look or behave just like this, but just a way for me
to see what has been entered.

so then it creates a text file and all the values need to be separated
by a comma, so the end result
would be
data.txt
-----------------------------------------------------------------------------------
Source, F:\pictures\pho tos,
Destination, \\Chuckwhite\c\ My Shared Folder,
A, 394859, 493029, 584920, 938934, 843234, 839238, 950535, 3438595,
349450, 239405, 839049,
930499, 039483,
B, 304893, 930984, 930945, 948404, 340594, 483920, 849302, 483920,
849472, 138594, 039483,
585048, 9302938, 893849, 9304849, 938403, 823940, 734892, 83749, 847433,
-------------------------------------------------------------------------------------
Any help or suggestions on how to do this is appreciated,
Chuck

Jul 20 '05 #1
6 8223
chuck clark hu kiteb:
Hi,
I understand that for security and other reasons that javascript
does not support writing/reading
to text files. I am looking for a way that will however.


Eh? I thought you just that you understood it to be impossible.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #2
chuck clark wrote:
Hi,
I understand that for security and other reasons that javascript does
not support writing/reading
to text files. I am looking for a way that will however.
This is what i am trying to do. I want to develop a simple html page
that is run locally on a windows
2000 box in IE. The page will have a browse button to select a source
folder, either locally or a network
computer on same lan. A destination folder, either locally or a network
computer on same lan
These two paths will be written to a text file.
Then the page has two fields, A and B. Both A and B have their own
'Add' Buttons. So I would
enter a number into either field A or B and hit add. Then the whole
form has a Reset and Submit Button. So once I was done entering all the
data into
all fields, I would hit submit and create a text file from it. I made
this quickly to give an idea
http://www.largeprojections.com/js/page1.htm

One thing i would like to do is display all the data I have entered, so
once I select the Source folder,
it displays on the page. Likewise with the data in Fields A and B once
I add it.
So the page may look like this
http://www.largeprojections.com/js/page2.htm
It wouldn't have to look or behave just like this, but just a way for me
to see what has been entered.

so then it creates a text file and all the values need to be separated
by a comma, so the end result
would be
data.txt
-----------------------------------------------------------------------------------

Source, F:\pictures\pho tos,
Destination, \\Chuckwhite\c\ My Shared Folder,
A, 394859, 493029, 584920, 938934, 843234, 839238, 950535, 3438595,
349450, 239405, 839049,
930499, 039483,
B, 304893, 930984, 930945, 948404, 340594, 483920, 849302, 483920,
849472, 138594, 039483,
585048, 9302938, 893849, 9304849, 938403, 823940, 734892, 83749, 847433,
-------------------------------------------------------------------------------------

Any help or suggestions on how to do this is appreciated,
Chuck


I know that Hyper Text Applications (HTA) allow you to override a lot of
security features... and I _thought_ you could write files with it, but
I am not sure. It only works with IE, but it sounds like that with your
requirements, this might not be a problem.

I know that MSDN has minimal documentation for the HTA technology. I
also know that there are a few other platform-specific technologies that
do this type of thing, but I cant think of them off the top of my head.
They end up being extensions.

Brian

Jul 20 '05 #3

"Brian Genisio" <Br**********@y ahoo.com> wrote in message news:40******** @10.10.0.241...
chuck clark wrote:
Hi,
I understand that for security and other reasons that javascript does
not support writing/reading
to text files. I am looking for a way that will however.
This is what i am trying to do. I want to develop a simple html page
that is run locally on a windows
2000 box in IE. The page will have a browse button to select a source
folder, either locally or a network
computer on same lan. A destination folder, either locally or a network
computer on same lan
These two paths will be written to a text file.
Then the page has two fields, A and B. Both A and B have their own
'Add' Buttons. So I would
enter a number into either field A or B and hit add. Then the whole
form has a Reset and Submit Button. So once I was done entering all the
data into
all fields, I would hit submit and create a text file from it. I made
this quickly to give an idea
http://www.largeprojections.com/js/page1.htm

One thing i would like to do is display all the data I have entered, so
once I select the Source folder,
it displays on the page. Likewise with the data in Fields A and B once
I add it.
So the page may look like this
http://www.largeprojections.com/js/page2.htm
It wouldn't have to look or behave just like this, but just a way for me
to see what has been entered.

so then it creates a text file and all the values need to be separated
by a comma, so the end result
would be
data.txt
-----------------------------------------------------------------------------------

Source, F:\pictures\pho tos,
Destination, \\Chuckwhite\c\ My Shared Folder,
A, 394859, 493029, 584920, 938934, 843234, 839238, 950535, 3438595,
349450, 239405, 839049,
930499, 039483,
B, 304893, 930984, 930945, 948404, 340594, 483920, 849302, 483920,
849472, 138594, 039483,
585048, 9302938, 893849, 9304849, 938403, 823940, 734892, 83749, 847433,
-------------------------------------------------------------------------------------

Any help or suggestions on how to do this is appreciated,
Chuck

I know that Hyper Text Applications (HTA) allow you to override a lot of
security features... and I _thought_ you could write files with it, but
I am not sure. It only works with IE, but it sounds like that with your


HTA DOES allow read/write to the local file system....

http://msdn.microsoft.com/workshop/a...taoverview.asp
requirements, this might not be a problem.

I know that MSDN has minimal documentation for the HTA technology. I
also know that there are a few other platform-specific technologies that
do this type of thing, but I cant think of them off the top of my head.
They end up being extensions.

Brian

Jul 20 '05 #4
Hi,

Fabian wrote:
chuck clark hu kiteb:

Hi,
I understand that for security and other reasons that javascript
does not support writing/reading
to text files. I am looking for a way that will however.

Eh? I thought you just that you understood it to be impossible.


He never said it was impossible. He said that JavaScript does not
support it, which is correct (at least client-side JavaScript). However,
there are possibilities, using Java classes or ActiveX technology (which
is not JavaScript, but which can be scripted).

However, the security model of browsers often blocks this, at least in
normal security conditions.

Hereunder an example that I use with local HTML files or HTA applications.

Laurent

CExplorer.ALERT 001 = "This method works only in Netscape 4.* "
+ "and Internet Explorer";
CExplorer.ALERT 002 = "The file already exists, overwrite?";
CExplorer.ALERT 003 = "This method works only on Windows platforms.";

CExplorer.saveT extFile = function( strFullPath, strContent, bOverwrite )
{
if ( ( navigator.appNa me != "Netscape" )
&& ( navigator.appNa me != "Microsoft Internet Explorer" ) )
{
alert( CExplorer.ALERT 001 );
return;
}

if ( ( navigator.appNa me == "Netscape" )
&& ( parseFloat( navigator.appVe rsion ) >= 5 ) )
{
alert( CExplorer.ALERT 001 );
return;
}

if ( navigator.platf orm.indexOf( "Win" ) == -1 )
{
alert( CExplorer.ALERT 003 );
return;
}

if ( navigator.appNa me.indexOf( "Netscape" ) == -1 )
{
var fso = new ActiveXObject( "Scripting.File SystemObject" );

if ( bOverwrite
|| !fso.FileExists ( strFullPath )
|| confirm( CExplorer.ALERT 002 ) )
{
var flOutput = fso.CreateTextF ile( strFullPath, true );
flOutput.Write( strContent );
flOutput.Close( );
return true;
}
else
{
return false;
}
}
else
{
netscape.securi ty.PrivilegeMan ager.enablePriv ilege(
"UniversalFileR ead" );

var flCheck = new java.io.File( strFullPath );

if ( bOverwrite
|| !flCheck.exists ()
|| confirm( CExplorer.ALERT 002 ) )
{
netscape.securi ty.PrivilegeMan ager.enablePriv ilege(
"UniversalFileW rite" );
var fsOutput = new java.io.FileOut putStream( strFullPath );
var flOutput = new java.io.DataOut putStream( fsOutput );

flOutput.writeB ytes( strContent );

flOutput.flush( );
fsOutput.close( );
return true;
}
else
{
return false;
}
}
}
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #5
"Laurent Bugnion, GalaSoft" <ga*********@bl uewin.ch> wrote in message news:<40******* ***@news.bluewi n.ch>...
Hi,

Fabian wrote:
chuck clark hu kiteb:

Hi,
I understand that for security and other reasons that javascript
does not support writing/reading
to text files. I am looking for a way that will however.

Eh? I thought you just that you understood it to be impossible.


He never said it was impossible. He said that JavaScript does not
support it, which is correct (at least client-side JavaScript). However,
there are possibilities, using Java classes or ActiveX technology (which
is not JavaScript, but which can be scripted).

However, the security model of browsers often blocks this, at least in
normal security conditions.

Hereunder an example that I use with local HTML files or HTA applications.

Laurent

CExplorer.ALERT 001 = "This method works only in Netscape 4.* "
+ "and Internet Explorer";
CExplorer.ALERT 002 = "The file already exists, overwrite?";
CExplorer.ALERT 003 = "This method works only on Windows platforms.";

CExplorer.saveT extFile = function( strFullPath, strContent, bOverwrite )
{
if ( ( navigator.appNa me != "Netscape" )
&& ( navigator.appNa me != "Microsoft Internet Explorer" ) )
{
alert( CExplorer.ALERT 001 );
return;
}

if ( ( navigator.appNa me == "Netscape" )
&& ( parseFloat( navigator.appVe rsion ) >= 5 ) )
{
alert( CExplorer.ALERT 001 );
return;
}

if ( navigator.platf orm.indexOf( "Win" ) == -1 )
{
alert( CExplorer.ALERT 003 );
return;
}

if ( navigator.appNa me.indexOf( "Netscape" ) == -1 )
{
var fso = new ActiveXObject( "Scripting.File SystemObject" );

if ( bOverwrite
|| !fso.FileExists ( strFullPath )
|| confirm( CExplorer.ALERT 002 ) )
{
var flOutput = fso.CreateTextF ile( strFullPath, true );
flOutput.Write( strContent );
flOutput.Close( );
return true;
}
else
{
return false;
}
}
else
{
netscape.securi ty.PrivilegeMan ager.enablePriv ilege(
"UniversalFileR ead" );

var flCheck = new java.io.File( strFullPath );

if ( bOverwrite
|| !flCheck.exists ()
|| confirm( CExplorer.ALERT 002 ) )
{
netscape.securi ty.PrivilegeMan ager.enablePriv ilege(
"UniversalFileW rite" );
var fsOutput = new java.io.FileOut putStream( strFullPath );
var flOutput = new java.io.DataOut putStream( fsOutput );

flOutput.writeB ytes( strContent );

flOutput.flush( );
fsOutput.close( );
return true;
}
else
{
return false;
}
}
}

You could add more branches and then use JavaScript via XPCOM to read
or write to local files in Mozilla and Netscape 7. Check out the
following link for details:

http://www.faqts.com/knowledge_base/...d/23360/fid/53
Jul 20 '05 #6
Hi Mark,

Mark Szlazak wrote:
You could add more branches and then use JavaScript via XPCOM to read
or write to local files in Mozilla and Netscape 7. Check out the
following link for details:

http://www.faqts.com/knowledge_base/...d/23360/fid/53


Thanks a lot for that. I was looking for this kind of things, without
having had the time to do a correct research and actually find the solution.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4257
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML) and puts values in a number of arrays and then puts the contents of the array in a HTML table. I'd like to keep the array structure. I've checked out all sorts of different javascript parsers but have not met with a great deal of success with any...
22
38534
by: Weston C | last post by:
I know of course that you can use <script src=""></script> in an HTML document to include javascript code you don't want to spill all over the page. I'm wondering if there's a way to include other pieces of javascript code from *within* javascript.... a la #include in C, @import in Java, use/require in Perl, include()/require() in PHP, etc.... Thanks, Weston
4
3830
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following beautiful script "http://javascript.internet.com/navigation/toolbar-menu.html". It works like a charm. I made my webpage in frames, where the nav-frame shows the menubar, so whenever I click a link in the menubar, it opens in the frame below. But...
16
1711
by: Christopher Benson-Manica | last post by:
Can anyone tell me which browsers implement Javascript 1.3? Specifically, which browsers will handle the identity operator (===) correctly? I ask because jslint suggests using it, but I don't want to get too cutting edge. -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
5
2196
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore anything I'll write should be stuck on a single file. I thought about creating a funny pop-up. <a href="javascript:myFunction();"... that's because, as you will see, the code for the popup is pretty complex. I've insterted myFunction somewhere...
26
15215
by: Don | last post by:
I'm writing an html page with some JavaScript that reads a web page into a client-side temp file, then reformats it, then submits that same file as a URL to the browser for display, via "locate.replace". I can do all this if the html page containing the script originates on the client machine, but don't know how to get access to a client-side temp file when the same html page containing the script is on a web host. How do I get access...
3
11820
by: Brit | last post by:
Hello, I have been trying to include a js file from within another js file. I can get this to work for firefox, but not i.e. What I have is a.html ... <script language='JavaScript' src='b.js'></script><script>Function();</script> b.js .... function Function() {
5
7776
by: mgershma | last post by:
Hi. Does anybody know how can JavaScript get the filename of the file it's located in? For example, file 'mike.js' contains several functions and variables. I would like to set the variable to the filename of this file dynamically:
2
2176
by: verci | last post by:
Hi guys, sorry if this seems stupid but I'm a newbie, I'm running Windows XP Pro SP2, IE 7, VS2005, ASP.net 2.0 The problem is that I'm trying to display this news scroller made in a Javascript file(newsscroller.js) in my ASP page, everything works great in a normal HTML page, I can see the scroller just fine, but in an ASP page it just does not show, I get some error message that the control has not been initialize, so far I've been...
1
3362
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript recordset varible when user click the save button then some values save in the database so i write javascript function to add the records... here is the code
0
8192
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8358
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7188
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1504
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.