vbscript - 对象不支持此方法
问题描述
我得到一个
对象不支持此方法
当我单击开始按钮时。它说这条线是;
<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>
我目前只是想用一个程序来运行这个程序。这是概念验证测试。
解决方案
好的,既然我想通了,我想我会在下面添加完成的脚本。所有这一切都是检查是否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>
推荐阅读
- java - 可靠地获取 LDAP (AD) 更新
- java - 使用 application.yml/properties 的批处理侦听器的 Spring kafka 集成属性
- spring-boot - Spring Boot如何在启动过程中干净地关闭
- gcc - Cortex-M3 (EFM32GG) - Newlib-Nano 的 ARM-GCC 链接器标志
- java - 无法在 spring-data-elasticsearch 的测试中注入存储库
- r - 如何将x-ticks设置为R中时间序列中的日期
- java - 当 Activity 可见时如何运行函数?( onResume 不能正常工作)
- python - 从/使用函数参数作为键和默认值作为值创建字典
- python - 使用 Python Bokeh 从同一数据集中绘制多条线
- javascript - 给出 HashTags 建议的算法