SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Save content texbox

    Hello

    I have this code
    Code:
    http://jsfiddle.net/G8vXL/
    When i write into textarea, save the file and make download....the file is empty. What's wrong?

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found this:

    Code:
    http://pixelgraphics.us/downloadify/test.html
    When I put text with line breaks, and then keep the text on the disc is not with line breaks.

    Anyone know help me?

  3. #3
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by Fantastic5 View Post
    Anyone know help me?
    I just had a look at the plugin you link to.
    I created a dummy text with a few line breaks in it, then saved it to disk.
    When I opened the file with Windows Notepad, the line breaks had been ignored.
    However, opening the same file with any other editor (SciTe, DreamWeaver, Wordpad) caused the line breaks to be honoured.

    Are you testing this in Windows Notepad?
    This link explains why this is happening: http://superuser.com/questions/36208...ing-linebreaks

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    I just had a look at the plugin you link to.
    I created a dummy text with a few line breaks in it, then saved it to disk.
    When I opened the file with Windows Notepad, the line breaks had been ignored.
    However, opening the same file with any other editor (SciTe, DreamWeaver, Wordpad) caused the line breaks to be honoured.

    Are you testing this in Windows Notepad?
    This link explains why this is happening: http://superuser.com/questions/36208...ing-linebreaks
    I only have tried just with notepad, with another software works.
    It's impossible solve the problem?

  5. #5
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    You cannot change the behaviour of Notepad, so the only option is to change the output of the plugin.
    If you look at the example you link to, you can see that it determines what to save to the text file thus:

    Code JavaScript:
    data: function(){ 
      return document.getElementById('data').value;
    }

    so you could hook in to that to filter out all new line characters and replace them with carriage returns.

    e.g.

    Code JavaScript:
    data: function(){ 
      var text = document.getElementById('data').value;
      return text.replace(/\n/g, "\r\n");
    }

    That might affect things in other editors, however.

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    You cannot change the behaviour of Notepad, so the only option is to change the output of the plugin.
    If you look at the example you link to, you can see that it determines what to save to the text file thus:

    Code JavaScript:
    data: function(){ 
      return document.getElementById('data').value;
    }

    so you could hook in to that to filter out all new line characters and replace them with carriage returns.

    e.g.

    Code JavaScript:
    data: function(){ 
      var text = document.getElementById('data').value;
      return text.replace(/\n/g, "\r\n");
    }

    That might affect things in other editors, however.
    Tried that, but still did not work.

  7. #7
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by Fantastic5 View Post
    Tried that, but still did not work.
    Really?
    Works for me.

    Here's a demo.

    Go to the demo page, enter something of at least two lines into the text area, save the file to your PC and open it with Notepad (normally: right click file -> open).
    If I do this on Win8 I see the output formatted correctly with line breaks.

    What do you see?

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Really?
    Works for me.

    Here's a demo.

    Go to the demo page, enter something of at least two lines into the text area, save the file to your PC and open it with Notepad (normally: right click file -> open).
    If I do this on Win8 I see the output formatted correctly with line breaks.

    What do you see?
    I forgot this: var text

    Thanks again!!


Bookmarks

Posting Permissions

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