Solved

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

Posted on 2009-05-14
6
552 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
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.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now