I am extracting content from a web page using JS/JQuery and want to write the data to a comma separated file. I know javascript doesn't really support file io and I'm trying to avoid setting up a local apache server just to process the content to a file. Is there an easier way to do this?
A:
You can write a Mozilla Extension.
PROs:
You can use JS/JQuery on the extension You can write files on the extension
CONs:
You can only use the application in Firefox (or any other Mozilla based browser).
Pablo Santa Cruz
2009-12-10 17:26:51
+4
A:
You can have your JS create the file text in a string. Then open a new window and write the string into the new window.
Scott Saunders
2009-12-10 17:33:02
Basically what I was going to suggest. Once you write it into a window the user can just do File > Save As to save the CSV to their computer. If you generate a data URI you could even specify content-type, ensuring that they get plaintext: http://en.wikipedia.org/wiki/Data_URI_scheme
Jordan
2009-12-10 17:38:41
A:
There is no simple way of doing this. W3C has recently published the first draft of a File API that will make it possible, but it'll be a while until this is through and widely implemented.
Thomas Kappler
2009-12-10 17:33:19
A:
Still requires a webserver, but you could build a small one method web service that your js calls, then the service can write out the data.
BioBuckyBall
2009-12-10 17:33:37