简体   繁体   English

使用HTML执行VBScript文件

[英]Execute VBScript file using HTML

I'm trying to Execute the following .vbs file using HTML. 我正在尝试使用HTML执行以下.vbs文件。 But it is not executing this. 但它没有执行此操作。 When i'm executing the .vbs file using command promt, it is working. 当我使用命令promt执行.vbs文件时,它正在工作。 But while trying to execute from HTML, it is not working. 但是在尝试从HTML执行时,它无法正常工作。

demo.vbs file demo.vbs文件

Dim IE
 Set IE = CreateObject("InternetExplorer.Application")
 IE.Visible = 1 
 IE.navigate "http://testingwebpage/web"
 Do While (IE.Busy)
   WScript.Sleep 10
 Loop 
Set Helem = IE.document.getElementsByTagName("select")(0)
Helem.Click
WScript.Sleep 10000
Set Helem = IE.document.getElementByID("searchOptions_listbox").getElementsByTagName("li")(3)
Helem.Click
Set Helem = IE.document.getElementByID("orderNumberInput")
 Helem.Value="990462"
Set Helem = IE.document.getElementsByTagName("a")(9)
 Helem.Click

test.html 的test.html

<html>

<head>
<title>printHello() Function in an Include File</title>

<script type="text/vbscript" src="demo.vbs"></script>

</head>
<body>
<button onclick="vbscript:MyFunc()">Click me</button> 
</body>
</html>

Thanks for the Answers..!! 谢谢你的回答.. !!

This will not solve your problem, but you are calling a function MyFunc which is not declared (apparently) in the Vbscript 这不会解决您的问题,但您正在调用一个未在Vbscript中声明(显然)的函数MyFunc

your code should be: 你的代码应该是:

Public Function MyFunc
     'your code
End Function

written like you did, the code will execute at the page loading, not after clicking the button 像你一样编写,代码将在页面加载时执行,而不是在单击按钮后执行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM