Solved

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

Posted on 2009-05-14
6
580 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:Tim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Tim
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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:Tim
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:Tim
ID: 31581688
Thanks
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

738 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