范例:
Private Sub WB_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim i, j
Dim xo, yo
For i = 0 To WB.Document.All.length - 1
If UCase(WB.Document.All(i).tagName) = "INPUT" Then
Set xo = WB.Document.All(i)
If LCase(xo.Type) = "text" Then
xo.Value = "OKOK"
End If
End If
If WB.Document.All(i).tagName = "TEXTAREA" Then
Set xo = WB.Document.All(i)
xo.Value = "Textarea"
End If
Next i
End SubPrivate Sub Command5_Click()
Dim vDoc, vTag
Dim i As Integer
Set vDoc = WB.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If LCase(vTag.Type) = "submit" Then
Debug.Print "sub"
vTag.Select
vTag.Click
Exit Sub
End If
End If
Next i
End SubPrivate Sub Command1_Click()
WB.Navigate "www.yahoo.com.cn"
End SubWB是Webbrowser控件,点击Command1浏览 Command5点击按钮。首先你需要在
References定义中加入Microsoft HTML Object Library
Private Sub WB_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim i, j
Dim xo, yo
For i = 0 To WB.Document.All.length - 1
If UCase(WB.Document.All(i).tagName) = "INPUT" Then
Set xo = WB.Document.All(i)
If LCase(xo.Type) = "text" Then
xo.Value = "OKOK"
End If
End If
If WB.Document.All(i).tagName = "TEXTAREA" Then
Set xo = WB.Document.All(i)
xo.Value = "Textarea"
End If
Next i
End SubPrivate Sub Command5_Click()
Dim vDoc, vTag
Dim i As Integer
Set vDoc = WB.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If LCase(vTag.Type) = "submit" Then
Debug.Print "sub"
vTag.Select
vTag.Click
Exit Sub
End If
End If
Next i
End SubPrivate Sub Command1_Click()
WB.Navigate "www.yahoo.com.cn"
End SubWB是Webbrowser控件,点击Command1浏览 Command5点击按钮。首先你需要在
References定义中加入Microsoft HTML Object Library
解决方案 »
- 救救我呀,我的笔记本淋雨了!
- 最近有想换工作的吗(VB开发)
- 今天VB突然不好使了,好奇怪,高手帮忙看看?工程可以打开,再打开窗体就死掉,是vb没有响应,其它应用程序没问题
- 那个英雄能让这个程序的菜单项 d 变为有效?打开后会有美眉出现!
- TDBGrid 7。0 中,在于ADODC1绑定的情况下,当ADODC1.refresh后,表格里的字符型数据全都充满了空格(长度为限制长度)
- 用vb录音调用api函数
- 请sxfzu(Flying)接分。。谢谢。
- 关于sendkeys和自动输入的问题!急!!
- VB中不能加载DataRefer.ocx
- 请问怎么在datagrid 的单元格里面怎么添加一个下拉列表,就是在单元格里面一点就可以出现一个下拉列表,里面存放里不同的数据
- VB超酷控件我下载了,愿与您共享!!!但.....我要注册码!!!
- 关于发表软件
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsForward"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit Dim oObject As Object
Dim sMethod As String
Dim bInstantiated As Boolean
Public Sub Class_Initialize() bInstantiated = False
End SubPublic Sub Set_Destination(oInObject As Object, sInMethod As String) Set oObject = oInObject
sMethod = sInMethod
bInstantiated = True
End SubPublic Sub My_Default_Method()
Attribute My_Default_Method.VB_UserMemId = 0 If bInstantiated Then
CallByName oObject, sMethod, VbMethod
End If
End Sub'===========================
然后在你的程序的web_DocumentComplete里加入:
Dim cfForward As clsForward
Set cfForward = New clsForward
cfForward.Set_Destination Me, "DocLink"
web(index).Document.All("ASUBMIT").onclick = cfForward然后加入你的DocLink函数:
Public Sub DocLink()
End Sub
这里的ASUBMIT是一个超连接的class ID,当点这个超连接时会触发 DocLink
类似的,按钮什么都一样。
同样的,通过document对象,你可以访问Webbrowser里的任何对象,比如 inputBox.Value 就象在DHTML/ javascript中做的那样。所要注意的一定要等 Document完全生成、读到内存并显示以后才能这样做,通过on error的技巧可以处理这个随机出现的问题
多说一句:对于javascript注意大小写。
再多说一句:给分吧 :)