再发一个WEBBROWSER的问题

northwolves 2009-08-09 07:35:46
WEBROWSER打开“http://www.solomonbrothers.com/DiamondSearch.aspx”后,



page=10

WebBrowser1.Navigate2 "javascript:updateResults(" & page & ");", False
没有翻到第10页

WebBrowser1.document.All("ctl00$ContentPlaceHolder$ProductPagerTop$PageSize").Value = 60
也没有实现每页显示60条记录
...全文
158 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
嗷嗷叫的老马 2009-08-10
  • 打赏
  • 举报
回复
同上....................
wuwenchun168 2009-08-10
  • 打赏
  • 举报
回复
太高深~只能帮顶~
ldy888 2009-08-09
  • 打赏
  • 举报
回复
嘻嘻,楼主可不是菜鸟
fantasis 2009-08-09
  • 打赏
  • 举报
回复
还有你得换换行,不然LZ要晕的
fantasis 2009-08-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ldy888 的回复:]
2 是 显示60条记录 , 9 是第10 页,用用一个onchange 就可以
VB code
WebBrowser1.Document.all("ctl00_ContentPlaceHolder_ProductPagerTop_PageSize").selectedIndex=2With WebBrowser1.Document.all("ctl00_ContentPlaceHolder_ProductPagerTop_PageIndex")
.selectedIndex=9
.onchangeEndWith
[/Quote]

上面两次onchange其实我注释掉了一个 - -
打多了,懒得删,就注释掉咯,只按一个键多好啊
ldy888 2009-08-09
  • 打赏
  • 举报
回复
2 是 显示60条记录 , 9 是第10 页,用用一个onchange 就可以

WebBrowser1.Document.all("ctl00_ContentPlaceHolder_ProductPagerTop_PageSize").selectedIndex = 2
With WebBrowser1.Document.all("ctl00_ContentPlaceHolder_ProductPagerTop_PageIndex")
.selectedIndex = 9
.onchange
End With
fantasis 2009-08-09
  • 打赏
  • 举报
回复
呃。。。item(2)才是60/页
我粗心惯了,凑合看吧
给你发个我测试好的代码,你要的两个问题都在里面

添加command1,command2,command3,webbrowser四个控件,
按command1是选一个形状,按command1是60/页,按command2是跳到第10页


Private Sub Command1_Click()
Dim x
Set x = WebBrowser1.Document.getelementbyid("ctl00_ContentPlaceHolder_ctl06_0")
x.Checked = True '用checkbox选一个形状,我选的round
Call x.onclick
End Sub

Private Sub Command2_Click()
Dim x
Set x = WebBrowser1.Document.getelementbyid("ctl00_ContentPlaceHolder_ProductPagerTop_PageSize")
x.Item(2).Selected = True '60条每页
Call x.onchange
End Sub

Private Sub Command3_Click()
Dim x
Set x = WebBrowser1.Document.getelementbyid("ctl00_ContentPlaceHolder_ProductPagerTop_PageIndex")
'Call x.onchange
x.Item(9).Selected = True '第10页
Call x.onchange
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.solomonbrothers.com/DiamondSearch.aspx"
End Sub



看到了吧,其实所有的代码都是加上一个 call 对象.触发函数,checkbox是onclick,combo是onchange
fantasis 2009-08-09
  • 打赏
  • 举报
回复
错了 刚才没仔细看 这是个select元素
刚才那个代码是用在checkbox元素的

select元素这么用:

dim x
set x = webbrowser.document.getelementbyid("ctl00_ContentPlaceHolder_ProductPagerTop_PageSize")
x.item(1).selected=true '这里的1就是你要的60条每页,combo好理解吧?这个combo的listindex
call x.onchange
fantasis 2009-08-09
  • 打赏
  • 举报
回复
选择了某个checkbox之后,把这个元素对象内的call执行一次,页面才会随之刷新

比如你给的网页代码
<select name="ctl00$ContentPlaceHolder$ProductPagerTop$PageSize" id="ctl00_ContentPlaceHolder_ProductPagerTop_PageSize" onchange="ResetPageIndex('ctl00_ContentPlaceHolder_ProductPagerTop_PageIndex'); OnLoadRecords('ctl00_ContentPlaceHolder_ProductPagerTop', 'ctl00_ContentPlaceHolder_ProductPagerTop_PageSize', 'ctl00_ContentPlaceHolder_ProductPagerTop_PageIndex');">

dim x
set x = webbrowser.document.getelementbyid("ctl00_ContentPlaceHolder_ProductPagerTop_PageSize")
x.selected=true
call x.onchange
lxq19851204 2009-08-09
  • 打赏
  • 举报
回复
支持一下 顶

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧