Sup3rkirby
05-07-2006, 10:53 AM
Hey, i'm sorry if this is a double post or anything, but i couldn't find anything on this in a search so i decided to post.
I had a script to save a file using the common dialog activex control, but it no longer works for me, so i have been trying to find some source code or samples for it and i have come up empty handed.
Does anyone have some quality, working script to save a file in javascript.
on a little side note, my code below gives me an error at the 'cDialog.ShowSave();'. I have the code below that in the body of my webpage.
function SaveJADEScript()
{
try
{
var GetScript;
GetScript = ReturnScript().replace(/</g,'<');
GetScript = GetScript.replace(/>/g,'>');
var tSaveData;
tSaveData = '<HTML><Head><Title>' + UserCaption + ' - Powered by: Visual JADE Script</Title></Head><Body>' + GetScript + '</Body></HTML>';
cDialog.Filter = "HTML Documents (*.html)|*.html|HTM Documents (*.htm)|*.htm)|Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
cDialog.ShowSave();
if(cDialog.filename > "")
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tDocument = fso.CreateTextFile(cDialog.filename, true);
tDocument.write(tSaveData);
tDocument.Close();
alert("'" + cDialog.filename + "' was saved!");
cDialog.filename = "";
} else {
return;
}
}
catch(e)
{
var sCancel = "true";
alert("The following error has occured:\n\n" + e);
}
}
<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
<PARAM NAME="LPKPath" VALUE="comdlg.lpk">
</OBJECT>
<OBJECT ID="CommonDialog1" WIDTH=32 HEIGHT=32
CLASSID="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB"
CODEBASE="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
</OBJECT>
I had a script to save a file using the common dialog activex control, but it no longer works for me, so i have been trying to find some source code or samples for it and i have come up empty handed.
Does anyone have some quality, working script to save a file in javascript.
on a little side note, my code below gives me an error at the 'cDialog.ShowSave();'. I have the code below that in the body of my webpage.
function SaveJADEScript()
{
try
{
var GetScript;
GetScript = ReturnScript().replace(/</g,'<');
GetScript = GetScript.replace(/>/g,'>');
var tSaveData;
tSaveData = '<HTML><Head><Title>' + UserCaption + ' - Powered by: Visual JADE Script</Title></Head><Body>' + GetScript + '</Body></HTML>';
cDialog.Filter = "HTML Documents (*.html)|*.html|HTM Documents (*.htm)|*.htm)|Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
cDialog.ShowSave();
if(cDialog.filename > "")
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tDocument = fso.CreateTextFile(cDialog.filename, true);
tDocument.write(tSaveData);
tDocument.Close();
alert("'" + cDialog.filename + "' was saved!");
cDialog.filename = "";
} else {
return;
}
}
catch(e)
{
var sCancel = "true";
alert("The following error has occured:\n\n" + e);
}
}
<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
<PARAM NAME="LPKPath" VALUE="comdlg.lpk">
</OBJECT>
<OBJECT ID="CommonDialog1" WIDTH=32 HEIGHT=32
CLASSID="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB"
CODEBASE="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
</OBJECT>