It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

How to write data in file with new line on Mozilla 2

How to write data in file with new line on Mozilla 2

Postby sonali09 on Thu Mar 19, 2009 5:55 am

Hi

I want to write data in file using java script, on Mozilla 2.

For that I wrote function as :

function FileWriteFF(sText)
{
alert ("FileWriteFF");

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

try
{
stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);

stream.init(file, 0x02 | 0x08 | 0x10, 0666, 0);

stream.write(sText,sText.length);


}

catch (e)
{
alert(e);
}

}

FileWriteFF("data");

With this is writing data continuously. If I want to write data on new
line, how to do that. I tried with "\n" , but it is not working.
sonali09
 
Posts: 1
Joined: Thu Mar 19, 2009 5:35 am

Re: How to write data in file with new line on Mozilla 2

Postby rangana on Thu Mar 19, 2009 4:26 pm

What language is this? I'm a bit baffled - it seemed like this isn't a usual JS.

Anyway, I'm not sure for a fix, but try to change this part:
Code: Select all
stream.write(sText,sText.length);


...with:
Code: Select all
stream.write(sText+'<br>',sText.length);


If nothing works, please provide a link to your page.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 6 guests