首页 > 解决方案 > 对象不支持此方法

问题描述

我得到一个

对象不支持此方法

当我单击开始按钮时。它说这条线是;

<input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button">

我相信它实际上可能在我的 vbscript 中的某个地方。当我单击开始按钮时,它取决于是否strPath输入并选中了复选框,它应该运行程序进行安装,或者告诉我我需要输入strPath或选中一个框。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Tombstone USD #1 - Software Installer</title>

    <HTA:APPLICATION
        APPLICATIONNAME = "Software Installer"
        ICON = "images\districtlogo.ico"
        ID = "NAME"
        BORDER = "thick"        
        CAPTION = "yes"
        SHOWINTASKBAR = "yes"
        SINGLEINSTANCE = "yes"
        SYSMENU = "yes"
        WINDOWSTATE="normal"
        SCROLL = "no"
        VERSION = "1.0"
        INNERBORDER = "yes"
        SELECTION = "yes"
        MAXIMIZEBUTTON = "no"
        MINIMIZEBUTTON = "no"
        NAVIGABLE = "no"
        CONTEXTMENU = "yes"
        BORDERSTYLE = "normal"
    />

    <script type="text/javascript">
    <!--Resolution//-->
        window.resizeTo(600,750);
    </script>

    <script language="VBScript">
        Sub Start_Button()

            Dim strAnswer,strPath, objNetwork
            Set objNetwork = CreateObject("WScript.Network")
            strAnswer = ""
            strPath=""

            If chkEset.Checked Then strAnswer = "Eset"

            'If strPath is empty then nothing was checked.
            If strPath = "" Then 
                Window.Alert "Please input Path location!"
            End If

            'If strAnswer is empty then nothing was checked.
            If strAnswer = "" Then 
                Window.Alert "Please Make an Selection!"
                Exit Sub
            End If

            Window.Alert "Done!"
        End Sub
    </script>   

</head>

<body style="background-color:#E6E6FA">
    <center>
        <img src="images\districtlogo.png" alt="Logo" height="100" width="100"/>
        <h1>Software Installer</h1>
    </center>

    <form name="MainMenu" action="" method="">
        <label for="sPath">Drive Letter or File Path:</label><input type="text" size="60" id="sPath" name="sPath"></td>
        <br />
        <label for="Eset">ESet AntiVirus</label></td><input type="checkbox" id="Eset" name="chkEset">
        <br />
        <input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button"> 
        <br />
        <input type="reset" value="Reset">

    </form>

</body>

</html>

我目前只是想用一个程序来运行这个程序。这是概念验证测试。

标签: vbscripthta

解决方案


好的,既然我想通了,我想我会在下面添加完成的脚本。所有这一切都是检查是否strPath已填写以及是否选中了复选框。下一步是让它运行与复选框对应的程序。

我修复它的方法是将其更改<input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button"><input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button()">.

我还意识到表单实际上并没有将值分配给脚本并创建TheForm值并将其分配给MainMenu表单。然后我不得不将该值添加到所有现有值中。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Tombstone USD #1 - Software Installer</title>

    <HTA:APPLICATION
        APPLICATIONNAME = "Software Installer"
        ICON = "images\districtlogo.ico"
        ID = "NAME"
        BORDER = "thick"        
        CAPTION = "yes"
        SHOWINTASKBAR = "yes"
        SINGLEINSTANCE = "yes"
        SYSMENU = "yes"
        WINDOWSTATE="normal"
        SCROLL = "no"
        VERSION = "1.0"
        INNERBORDER = "yes"
        SELECTION = "yes"
        MAXIMIZEBUTTON = "no"
        MINIMIZEBUTTON = "no"
        NAVIGABLE = "no"
        CONTEXTMENU = "yes"
        BORDERSTYLE = "normal"
    />

    <script type="text/javascript">
    <!--Resolution//-->
        window.resizeTo(600,750);
    </script>

    <script language="VBScript">
        Sub Start_Button()

            Dim strAnswer,strPath, objNetwork,TheForm
            Set objNetwork = CreateObject("WScript.Network")
            Set TheForm = Document.MainMenu
            strAnswer = ""
            strPath = ""

            If TheForm.chkEset.Checked Then strAnswer = "Eset"            

           'If strPath is empty then nothing was checked.
            If TheForm.strPath = "" Then 
                Window.Alert "Please input Path location!"
                Exit Sub            
            End If

            'If strAnswer is empty then nothing was checked.
            If strAnswer = "" Then 
                Window.Alert "Please Make an Selection!"
                Exit Sub
            End If

            Window.Alert "Done!"
        End Sub
    </script>   

</head>

<body style="background-color:#E6E6FA">
    <center>
        <img src="images\districtlogo.png" alt="Logo" height="100" width="100"/>
        <h1>Software Installer</h1>
    </center>

    <form name="MainMenu" action="" method="">
        <label for="Path">Drive Letter or File Path:</label><input type="text" size="60" id="Path" name="strPath"></td>
        <br />
        <label for="Eset">ESet AntiVirus</label></td><input type="checkbox" id="Eset" name="chkEset">
        <br />
        <input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button()"> 
        <br />
        <input type="reset" value="Reset">

    </form>

</body>

</html>

推荐阅读