我制作了一个运行完美且运行良好的vbscript,以为我可以通过脚本标签将其插入到html中并执行相同的操作。不是,请告诉我需要做什么才能使按钮工作。作为一个脚本,它会自动登录并导航到一个页面,我想在我的网页上按下按钮时发生这种情况。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Add a Lead</title>
<script type="text/vbscript">
function Execute()
{
Dim IE
Dim WRI
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate "http://rentalapp.zillow.com/"
Do While (IE.Busy)
WScript.Sleep 10
Loop
Set WRI = IE.document.getElementByID("username")
WRI.Value = "username"
Set WRI = IE.document.getElementByID("password")
WRI.Value = "password"
Set WRI = IE.document.Forms(0)
WRI.Submit
WScript.Sleep 801
IE.navigate "http://rentalapp.zillow.com/leads/add/"
document.getElementById("field2").value=document.getElementById("field1").value; } </script> </head>
<body>
<button onclick="Execute()">Add A Lead</button>
</body>
</html>
请帮助
答案 0 :(得分:0)
我不是vbscript程序员,但我认为问题在于你的函数声明。这就是W3C为简单警报声明vbscript函数的方法example:
<script type="text/vbscript">
sub Execute()
MsgBox("Hello world")
end sub
</script>
<body>
<button onClick="Execute()">Add A Lead</button>
</body>