2010-10-27 56 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。