Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening and editing files in Javascript

    I've looked with Google, through Liorean's documentation threads and searched this forum, but I can't find how to open and edit files with Javascript! I thought it might be the classic var file = fopen('filename', 'mode'); but that doesn't seem to work. Any advice?
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #2
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never mind, I rephrased my search terms and it came up with a lot of different answers... bleh. This makes my life difficult.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it helps me'

    Here is one method Vinny posted once:
    Code:
    <script type="text/javascript">
    <!--//
    
    //-----------------------------------------------------------------------
    // author: Vincent Puglia
    // site: http://members.aol.com/grassblad
    //-----------------------------------------------------------------------
    
    function loadFile(oSrc, oDest)
    {
    var fso, oFile, contents
    var ForReading = 1
    var txtFile = oSrc.value;
    fso = new ActiveXObject("Scripting.FileSystemObject")
    oFile = fso.OpenTextFile(txtFile, ForReading)
    contents = oFile.ReadAll()
    
    oDest.value = contents;
    oFile.Close()
    }
    
    //-->
    </script>
    </head>
    <body>
    <form name="a">
    <input type="file" name="b">
    <input type="button" value="Load It" onclick='loadFile(this.form.b, this.form.c)'>
    <br>
    <textarea name="c" cols="80" rows="25"></textarea>
    
    </form>
    .....Willy


  •  

    Posting Permissions

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