HTA文件去除html控件認(rèn)證和接收命令行參數(shù)

字號(hào):


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