Re: Saving dynamically created data on client side?



HaJo wrote:
JS-rookie here... Apologies first, I guess this must have been asked a
million times. I googled back&forth, but all the answers I saw were
somehow drifting into different directions, not providing a
solution... Here's the problem:

You have not searched for "save as", have you?

I have a client-side javascript running, the user creates some data.
At a point the data should be saved to his HDD -- I.e. a "Save as...".
Format of the data, btw, is XML. I couldn't find any pointer on how to
do this client-side only, cross-browser/OS. Any idea how this can be
achieved?

It cannot be done in the desired way with client-side scripting as that
depends on the runtime environment for providing that feature.

If not possible, I'm thinking whether I should submit the data back to
the server into a cgi/php, temporarily storing the file on the server.
I guess the javascript could then pop a new window open, linking to
the server-side script.

It could even be done, and should be made possible too, without client-side
scripting at all.

That one could then serve the file, hopefully
triggering a "Open/Save" dialog box of the browser. But here I'm not
sure how to create, from the JS, a unique ID identifying the correct
handle for the cgi/php. I worry about race-conditions...

I do not see a race condition as your server would generate the file on the
fly, printing it to the standard output, upon request of a specific client
as response message to that client. You can make use of session IDs, though.

I'm currently asking the user to copy&paste the XML data into a new
document and save that. But that's probably the most user-unfriendly
way I could come up with :(

Yes.

Hints or thoughts are highly appreciated!

You are welcome.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@xxxxxxxxxxxxxxxx>
.



Relevant Pages

  • Re: ASP.Net Newbie Questions
    ... I think of JavaScript and stuff like form ... and the server has no memory either. ... The client-side event triggers a JavaScript function ... >> single page to only the appropriate functionality for that page. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How do I setup php script to return a browser page?
    ... > client-side page in my case ... > content via an array, have server A process the form, and rebuild (via ... an event handler for the 'onsubmit' event in javascript that would parse the ...
    (comp.lang.php)
  • Re: I need to write to a file.
    ... client-side as my Javascript program displays ... server is never involved. ... The required information only needs to be ... how to get Javascript to write out a file without HTTP ...
    (comp.lang.javascript)
  • Re: Displaying Timestamps Across Multiple Timezones in Web Part
    ... > I'm working within Sharepoint 2001 Portal Server. ... > want to see the time stamp in accordance with their time zone, ... > me that client-side Javascript must somehow get ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Javascript version in IIS
    ... I mean server side scripting version. ... Your function return the JScript engine version, not the Javascript ...
    (microsoft.public.inetserver.iis)