2019-09-05 07:30:43 (1215)


Private WithEvents HtmlDocument As MSHTML.HtmlDocument Private WithEvents HtmlElement As MSHTML.HTMLButtonElement 'code by lichmama from cnblogs.com Private Sub Form_Load() With WebBrowser1
        .Left = 0 .Top = 0 .Navigate "file://C:\Users\Administrator\Desktop\test.html" End With End Sub Private Sub Form_Resize() With WebBrowser1
        .Width = Me.Width
        .Height = Me.Height End With End Sub Private Sub Form_Unload(Cancel As Integer) Set HtmlElement = Nothing Set HtmlDocument = Nothing End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) With WebBrowser1 'get the HtmlDocument from webbrowser, ' and bind the control of button to [HtmlElement], ' and setup the event handler of [mybutton]'s onclick. Set HtmlDocument = .Document Set HtmlElement = HtmlDocument.getElementById("submit") End With End Sub Private Function HtmlDocument_oncontextmenu() As Boolean '屏蔽右键菜单 HtmlDocument_oncontextmenu = False End Function Private Function HtmlElement_OnClick() As Boolean 'in this section, we can do any operations to current page. ' think about it, if this is a submit button, we could verify the password, whatever. username = HtmlDocument.getElementById("login_username").Value
    password = HtmlDocument.getElementById("login_password").Value
    Debug.Print "your username:", username
    Debug.Print "your password:", password
    HtmlElement_OnClick = False End Function


 View Code


合作伙伴:万网 | 新网 | 新网互联 NDF网站建设淘宝店 | 实用工具 | 外貿網站建設 | 联系我们
©2006-2021 NDF Corporation Sitemap - RSSRSS订阅