views:

40

answers:

2

I would like to append a .txt file ussing HTML or java I know this is possible but keep on running into the ActiveX warning, which in this case is just annoying (we know ActiveX stop being so darn dogmatic)

is there just a simple way of scripting this without AxtiveX prompts?

The current script as follows (or at lest snippit of)

<title>fruit.txt </title>
<SCRIPT LANGUAGE='JavaScript'> 
function WriteToFile() { 
try { 
var fso, s; 
fso = new ActiveXObject("Scripting.FileSystemObject"); 
s = fso.OpenTextFile("C:\\TESTAPEND\\TESTAPEND.txt" , 8, 1, -2); 
s.writeline(document.ietmdata.name.value); 
s.Close(); 
} 
catch(err){ 
var strErr = 'Error:'; 
strErr += '\nNumber:' + err.number; 
strErr += '\nDescription:' + err.description; 
document.write(strErr); 
} 
} 


function WriteToFile2() { 
try { 
var fso2, s2; 
fso2 = new ActiveXObject("Scripting.FileSystemObject"); 
s2 = fso2.OpenTextFile("C:\\TESTAPEND\\TESTAPEND.txt" , 8, 1, -2); 
s2.writeline(document.ietmdata2.name2.value); 
s2.Close(); 
} 
catch(err2){ 
var strErr2 = 'Error:'; 
strErr2 += '\nNumber:' + err2.number; 
strErr2 += '\nDescription:' + err.description; 
document.write(strErr2); 
} 
} 

function WriteToFile3() { 
try { 
var fso3, s3; 
fso3 = new ActiveXObject("Scripting.FileSystemObject"); 
s3 = fso3.OpenTextFile("C:\\TESTAPEND\\TESTAPEND.txt" , 8, 1, -2); 
s3.writeline(document.ietmdata2.name2.value); 
s3.Close(); 
} 
catch(err2){ 
var strErr3 = 'Error:'; 
strErr3 += '\nNumber:' + err3.number; 
strErr3 += '\nDescription:' + err.description; 
document.write(strErr3); 
} 
} 

</SCRIPT> 
</head>
<body>

<p class=rvps3><span class=rvts13>Append acaddoc.lsp</span></p>
<p class=rvps2><img border=0 width=80 height=129 alt="" hspace=1 vspace=1 src="VTS_LOGO.jpg"></p>
<hr noshade size=1 style="color : #000000">
<p><span class=rvts10>Drawing Analyser 1.1</span></p>
<hr noshade size=1 style="color : #000000">
<p><br></p>
<p>

<center>If your Acaddoc.lsp file resides where AutoCAD installed them by default, simply click append next to the version of AutoCAD you want to apply the Drawing Analyser 1.1 program to. <br> <br> <br> <br> <table border="1"><tr><th> 

<form action="test.hta" method="post" name="ietmdata"> 
&nbsp; AutoCAD 2006 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <INPUT TYPE=BUTTON VALUE="APPEND" onClick="WriteToFile(this.form); window.location.href='Append_acaddoc_LSP_MODULE_2.html'"></table border="1"></tr></th><div id="myarea" style="visibility:hidden"> <textarea name="name" cols="40" rows="1"> 

Appels

</textarea> </div> 

</form> 

<table border="1"><tr><th> 

<form action="test.hta" method="post" name="ietmdata2"> 
&nbsp; AutoCAD 2009 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <INPUT TYPE=BUTTON VALUE="APPEND" onClick="WriteToFile2(this.form); window.location.href='Append_acaddoc_LSP_MODULE_2.html'"></table border="1"></tr></th><div id="myarea2" style="visibility:hidden"> <textarea name="name2" cols="40" rows="1"> 

Pears

</textarea> </div> 

</form> 

<table border="1"><tr><th> 

<form action="test.hta" method="post" name="ietmdata3"> 
&nbsp; AutoCAD 2010 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <INPUT TYPE=BUTTON VALUE="APPEND" onClick="WriteToFile3(this.form); window.location.href='Append_acaddoc_LSP_MODULE_2.html'"></table border="1"></tr></th><div id="myarea3" style="visibility:hidden"> <textarea name="name3" cols="40" rows="1"> 

Bannanas

</textarea> </div> 

</center></form> 
A: 

If you are seeing the activex prompt in IE on your local machine then don't worry you won't get that warning when you run the code on a server

FutureKode
lol, no this is for an inhouse "over a shared net work" project the warning show's...
nathan
A: 

You have several options but if ActiveX works for you, then I suggest you stick with it, because the prompts are there for a reason, it's a security risk, with any web application that wants to access your local file legally, it would normally pop a warning message because if not, as surely as the sun will rise tomorrow, it will be exploited.

You can also use Applet (Java) but this is overkill, but with the proper certificate, it will bypass many security warnings and questions. It's a heavy component in your web site but the advantage of this is that all Applet supporting browsers will be able to run your code, unlike when using ActiveX where you are limited to browser/s that support it.

Or you can wait for HMTL 5 to be developed, it should natively support File IO.

Manny