Saving local files in javascript under Opera

A

André Wagner

Hello,

I'm writing a HTML/javascript application who will run locally. I want
to save to a local file.

If I were using IE, I would do this way:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso_OpenTextFile(filePath,2,-1,0);
file.Write(content);
file.Close();

If I were using Mozilla, I would do like this:


netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file =
Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filePath);
if (!file.exists()) file.create(0, 0664);
var out =
Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
out.init(file, 0x20 | 0x02, 00004,null);
out.write(content, content.length);
out.flush();
out.close();

But I couldn't figure out how to do it using Opera. Does anyone has any
idea?

Thank you in advance,

André
 
R

Randy Webb

André Wagner said the following on 4/24/2006 1:10 PM:
Hello,

I'm writing a HTML/javascript application who will run locally. I want
to save to a local file.

If I were using IE, I would do this way:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso_OpenTextFile(filePath,2,-1,0);
file.Write(content);
file.Close();

If I were using Mozilla, I would do like this:


netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file =
Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filePath);
if (!file.exists()) file.create(0, 0664);
var out =
Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
out.init(file, 0x20 | 0x02, 00004,null);
out.write(content, content.length);
out.flush();
out.close();

But I couldn't figure out how to do it using Opera. Does anyone has any
idea?

<h1>Copy and paste this text to your text editor and save it:</h1>
<textarea>Data to be saved here</textarea>
 
L

Lasse Reichstein Nielsen

André Wagner said:
I'm writing a HTML/javascript application who will run locally. I want
to save to a local file. .....
But I couldn't figure out how to do it using Opera. Does anyone has any
idea?

Check out TwiddlyWiki (google to find it). They use Java through
Livescript to access files. It needs configuration to allow that, but
it works.

/L
 
M

Martin Honnen

André Wagner wrote:

I'm writing a HTML/javascript application who will run locally. I want
to save to a local file.
But I couldn't figure out how to do it using Opera. Does anyone has any
idea?

You could try it using LiveConnect making JavaScript to Java calls. But
I am not sure that works, it might cause Java security exceptions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top