2010-10-27 54 views
0

我想追加一个.txt文件尤斯HTML或Java,我知道这是可能的,但 继续运行到该ActiveX警告,在这种情况下,仅仅是烦人(我们知道的ActiveX不再是这么混账的教条)使用HTML/java追加?

有没有AxtiveX提示脚本的简单方法?

当前脚本如下(或免得SNIPPIT)

<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> 
+0

请显示您使用的代码。 – 2010-10-27 09:20:55

+0

其中是.txt文件的位置?在服务器或在客户端的PC? – Manny 2010-10-27 09:22:50

+0

在客户端电脑, – nathan 2010-10-27 09:27:54

回答

0

如果你看到你的本地计算机上的IE浏览器的activex提示再不用担心你的时候,你不会得到这一警告运行服务器上的代码

+0

哈哈,不,这是一个室内“共享网络工程”项目的警告节目... – nathan 2010-10-27 09:30:26

0

你有几个选择,但如果ActiveX适用于你,那么我建议你坚持下去,因为提示是出于某种原因,这是一个安全风险,任何Web应用程序都想要合法地访问您的本地文件,通常会弹出一条警告消息,因为如果没有,就像明天太阳会升起一样,它会被利用。

您也可以使用Applet(Java),但这是矫枉过正,但具有适当的证书,它将绕过许多安全警告和问题。这是你网站上的一个沉重的组件,但是这样做的好处是所有支持Applet的浏览器都能够运行你的代码,而不像在使用ActiveX的时候,你只能使用支持它的浏览器。

或者您可以等待开发HMTL 5,它应该本地支持文件IO。