www.webdeveloper.com
Results 1 to 4 of 4

Thread: File read/write using javascript for mozilla in unix

  1. #1
    Join Date
    Jun 2012
    Posts
    4

    File read/write using javascript for mozilla in unix

    How I read and write form data in to a txt file using js for mozilla browser in unix?
    Or is there any alternative way of using ActivexControll


    Thanks in advance

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    what kind of a text file?

    you can use a dataURL or an unknown mime type to trigger a file download. maybe this comes from an extension (don't remember) but you can associate certain MIME types with certain actions.

    if you associate your unique mime with "always save"ing the file, you can effectively save to the HD w/o intervention (other than the first time).


    Code:
    //fake data that could be from a form or whatev:
    var formData={age: 21, name: 'fred'};
    
    
    //a serialized version of that data for saving:
    var strData= formData.name+" is "+formData.age+" years old.";
    
    
    // build a virtual file url:
    var url="data:text/something-new," + escape(strData);
    
    //download the "file" by opening the url:
    window.open(url);

    don't forget to customize and remember your save/open action the first time it runs.

  3. #3
    Join Date
    Jun 2012
    Posts
    4
    thanks for your response but this works only on Mozilla.Can I make it for any browser?

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by aks1984 View Post
    thanks for your response but this works only on Mozilla.Can I make it for any browser?
    i dunno, can you?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles