Solved

how can I using javascript to save javascript value to a file

Posted on 2009-05-14
6
564 Views
Last Modified: 2012-05-07
I would like write a page using javascript . The user can load this page and then offline do some input. Then click one button to save the changed javascript value to a file on local disk. Any one can give me a solution?
0
Comment
Question by:zcfyhome
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:cevoman
ID: 24389428
Hi there,

For security reasons aside from a cookie Javascript does not allow a user to read or write local or server files
there is only really one way of allowing this and that's if the user has a activex control which is written for

but as standard it can't be done otherwise there would be more security issues on the web than there is already

Kind regards
James
0
 

Author Comment

by:zcfyhome
ID: 24389581
How about using document.execCommand('SaveAs'). I would like the user can save the information  as a file offine, later he can update this file.
0
 
LVL 3

Expert Comment

by:cevoman
ID: 24389708
The only issue is that document.execCommand('SaveAs'...) is only a IE implentation and if the user clicks file --> save as... or CTRL + S that will also work

I'm not aware there is anyway to do this in firefox as it could be a potential security risk on the clients side.

Kind regards
James
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:zcfyhome
ID: 24389746
Just IE is ok. The point is I do not want save whole page, just want save one javascript value as a txt file. Any solution?
Thanks
0
 
LVL 3

Accepted Solution

by:
cevoman earned 500 total points
ID: 24389823
You could do the below code and then have a button which calls a function and calls the below function with the appropriate data
function writeJSValue(newData)
	{
		var newWindow = window.open("",newWindow','width=1,height=1');
		newWindow.document.write(newData);
		newWindow.document.write("<script language=\"javascript\">document.execCommand('SaveAs')</script>");
		newWindow.document.close();
		newWindow.close();
	}

Open in new window

0
 

Author Closing Comment

by:zcfyhome
ID: 31581688
Thanks
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question