All files that I will be referring to are in the same file folder. I
need my javascipt file to write or save the contents of a textarea to
other local files. This is for local use only on one system.
I have no problem doing this in NN4 and IE.
However, I have problems with nn7 and moz1.4 even when I add this to my
prefs.js files:
user_pref("sign ed.applets.code base_principal_ support", true);
I've also added this to my java.policy files:
grant codeBase "file:///c:/mywebpagefilesd ir/*" {
permission java.security.A llPermission;
}
Here's the javascript code for IE and NN7. I'm always getting the alert
'Permission to write to file was denied.'.
function writeToFile(fn, txt) {
if (window.netscap e && navigator.javaE nabled) {
netscape.securi ty.PrivilegeMan ager.enablePriv ilege('Universa lFileWrite')
;
var f = new java.io.File(fn );
if (f.exists())
if (!confirm('file ' + fn + ' exists. Overwrite?'))
fn = prompt ('new file name: ', fn);
if (fn) {
try {
var fr = new java.io.FileWri ter(fn);
fr.write (txt);
fr.close();
return true;
}
catch(e) {
alert('Permissi on to write to file was denied.');
return false;
}
}
else
return false;
}
else if (document.all) {
var fs = new ActiveXObject(' Scripting.FileS ystemObject');
if (fs.FileExists( fn))
if (!confirm('file ' + fn + ' exists. Overwrite?'))
fn = prompt ('new file name: ', fn);
if (fn) {
var fr = fs.CreateTextFi le (fn, true);
fr.write (txt);
fr.close();
return true;
}
else
return false;
}
}
var fileName = 'c:/mywebpagefilesd ir/test.html';
if (writeToFile(fi leName,
'<html><head>< \/head><body><h2> Hello!<\/h2><\/body><\/html>'))
window.open(fil eName);
Specific help in making this work would be much appreciated!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!