CObject调用Webbrowser控件Document例子 VFB

yjgyjgg 2021-7-14 9399

    dim doc as CObject
    doc.SetObject me.WebBrowser1.Document'先获取WebBrowser1控件的文档接口
    doc.Get("getElementById"  ,"kw").Put("value"  ,"test")'调用getElementById方法获得百度kw文本框,并设置value为test
    if doc.IsErr Then PrintA doc.ErrDescription'显示错误
    doc.ClearErr'清除错误
    doc.Get("getElementById"  ,"su").Run("click")'获得百度一下按钮并点击
    Dim pw As CObject  = Doc.Get("parentWindow")'获得parentWindow接口
    pw.Run("execScript","alert('1')")'调用execScript方法运行js命令alert('1')

因国家互联网安全管理要求,关闭回帖功能。大家需要留言,请使用【勇芳软件客服】即时联系勇芳点此打开->>勇芳软件客服
返回
联系勇芳
发新帖 搜索 反馈 回顶部