2013-10-13 27 views
0

我做了一個運行和完美的作品一個VBScript,以爲我可以只需將其與腳本代碼的HTML,它會執行相同。不正確的,請告訴我,我需要做的就是按鈕的工作。作爲一個腳本會自動登錄並導航到一個頁面,我希望當按下我的網頁上一個按鈕,這樣的事情發生。我以爲我的VBScript按鈕會執行,但我可能失去了一些東西

<!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

花括號和分號不是在VBScript有效語法元素。另外,「不起作用」是不充分的問題描述。怎麼*確切*做它「不工作」?你有錯誤嗎? –

回答

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> 
+0

OK,這樣的作品,但它仍然不會輸入登錄信息。我再次提醒你,它可以作爲一個VBScript但在HTML死了,但至少你讓我到下一個步驟,併爲我謝謝你。在我甚至無法讓按鈕作出反應之前,現在它會用我分配的URL地址來拉出另一個窗口。 –

+0

是抱歉,我不能潛入代碼。但這聽起來像是兼容性問題。您是否意識到Visual Basic for Applications,VBScript和Visual Basic之間的區別? –

相關問題