Private Sub Form_Load()
Open App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "E.htm" For Binary As #1
Put #1, , "<form action=Vb:lap>Name:<input id=name><input type=submit value=Submit></form>"
Close #1
WebBrowser1.Navigate App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "E.htm"
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
If Left(URL, 3) = "vb:" Then
Cancel = True
MsgBox WebBrowser1.Document.body.All("Name").Value
End If
End Sub
还有一种方法:通过自定义事件来做
http://wenku.baidu.com/link?url=mmpAiaBqg1nx5EhYZz-Iz-9-L7E_4iJy7iF0_cV4Gqvvcuwxje5S4hfct47Av36D7SSmEFCdV-iZAPkX_HBsvdMRmP4zSGXhUjQjUu9N_07&qq-pf-to=pcqq.group