Forum Moderators: open

Message Too Old, No Replies

How to create a file using Javascript?

         

ericazhj

6:47 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Hi,

here, I want to create a in-memory or hard disk file using Javascript embed in html. I want to store some data. Thanks.

rocknbil

8:03 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't be done, if you could, imagine the security issues - anyone could load a Javascript tidbit in my browser and write me a sweeet lil' virus to track my movements and take over my computer. :-)

You can so some things with your server using Ajax, but on a user's local computer - no.

ericazhj

9:27 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Then could I read the content from a file?

Could I embed a program of Java into the script to do this kind of things?

Thanks.

kaled

11:30 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How much data do you want to store, for how long and why?

Kaled.

rocknbil

2:01 am on Mar 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From your server, you could use a server-side include,

<!-- #include file="some-file.txt" -->

Then if that loads in the page correctly, you could read the content with Javascript once it's in the page:

if (document.getElementById('some-id-from-include')) { ... }

But you can't do that on the client's side at all.

ericazhj

7:26 pm on Mar 11, 2007 (gmt 0)

10+ Year Member



Thanks a lot. Got it.