[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2009-05-14
6
Medium Priority
?
609 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

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 1500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 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