Save content texbox

Hello

I have this code

http://jsfiddle.net/G8vXL/

When i write into textarea, save the file and make download…the file is empty. What’s wrong?

I found this:

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?

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/362087/notepad-ignoring-linebreaks

I only have tried just with notepad, with another software works.
It’s impossible solve the problem?

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:

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.

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

That might affect things in other editors, however.

Tried that, but still did not work. :frowning:

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!! :slight_smile: