forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


JAVASCRIPT Question...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Tue Aug 19, 2003 12:45 pm    Post subject: JAVASCRIPT Question... Reply with quote

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... Sad
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 Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Aug 19, 2003 3:17 pm    Post subject: Reply with quote

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. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Wed Aug 20, 2003 8:42 am    Post subject: Reply with quote

I wouldn't hope such technique would actually work, it would pose a great security risk.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Wed Aug 20, 2003 11:01 am    Post subject: Reply with quote

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 Wink

Thanks FF for your suggestion.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Aug 20, 2003 1:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group