最近看vbscript程序員參考手冊第三版,講到hta的兩個應用
一是利用hta 去掉htm的控件驗證
hta1的代碼如下:
代碼如下:
<html>
<head>
<title>Sample HTML Application one</title>
</head>
<body onload="Viewer.document.location.href='activexcontrol.htm'">
<iframe id="Viewer" application="yes"><!--這里是去掉驗證的關鍵-->
</iframe>
</body>
</html>
activexcontrol.htm代碼如下:
代碼如下:
<script language="VBSCRIPT">
Dim FileSystem
' Creates the FileSystemObject
Set FileSystem = CreateObject("Scripting.FileSystemObject")
</script>
這樣就可以去掉htm的本地驗證了。
二、hta接收命令行參數
書中的代碼我估計有錯,不可能成功,我研究了一下,hta2應當這樣寫:
代碼如下:
<HTA:APPLICATION
ID="MySampleHTA"
Caption="yes">
<html>
<head>
<title>Sample HTML Application two</title>
</head>
<body>
<script language="VBScript">
cmdLineArray = Split(MySampleHTA.commandLine)‘這是把命令中的參數變成數組
MsgBox cmdLineArray(UBound(cmdLineArray)) '接收最后一個參數
a=document.getElementById("MySampleHTA").commandLine '這樣寫法是一個字符串,不是數組
MsgBox TypeName(a)&"--"&a '驗證
</script>
</body>
</html>
在命令行下:hta2 lcx 就會彈出lcx的對話框