| View previous topic :: View next topic |
| Author |
Message |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Tue Aug 19, 2003 12:45 pm Post subject: JAVASCRIPT Question... |
|
|
Hi, I know this is not really VDS related, but I trying to build a small javascript app that I want to use with my VDSSURFX. I simply want to save a bit of text to a file on the users machine using Javascript without the SAVEAS Dialog. The javascript would run locally on the users machine, not from a web server.
So far I have this that saves bits the DIV part to a file called myjob.js, but I get the ActiveX warning popup which I dont want:
| Code: | <HTML>
<BODY>
<DIV id="myScript" style="display:none">
<h1>aha</h1>
function doSmething() {
alert('Doing...')
}
</DIV>
<SCRIPT>
function SaveFile(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var MyFile = fso.CreateTextFile("C:\\myjob.js", true);
MyFile.Write(myScript.innerText);
MyFile.Close();
}
</SCRIPT>
This is text from the main page.<BR>
<A HREF=# onClick="SaveFile()">Click to save DIV</A>
</BODY>
</HTML> |
Or this which works but have the SAVEAS Dialog...
| Code: | <HTML>
<BODY>
<input type="BUTTON" name="btnSave" value="Save Text"
onclick="javascript:document.execCommand('SaveAs','False','myjob.txt')">
</BODY>
</HTML> |
I would rather have the second option without the SAVEAS dialog... Is it possible? Any javascript guru that can help me or direct me to a good link to help me out ? Thanks  |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Aug 19, 2003 3:17 pm Post subject: |
|
|
I would steer clear of writing to files. You're going to get all sorts of Anti-Virus
alerts and warnings. It would be best to, say, create a java applet that
does it for you.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Wed Aug 20, 2003 8:42 am Post subject: |
|
|
| I wouldn't hope such technique would actually work, it would pose a great security risk. |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Wed Aug 20, 2003 11:01 am Post subject: |
|
|
Yup your right. I tought when the Javascript was execute from the local machine and not the web server it could be done.
Anyway I will find another solution
Thanks FF for your suggestion. |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 20, 2003 1:19 pm Post subject: |
|
|
You might try running it in an HTA. That supposedly has no security
restrictions. But still an AV Program might catch it. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|