如何用webbrowser获取网页弹出窗口中的内容

2025-03-13 09:07:51
推荐回答(1个)
回答1:

WebBrowser.Silent = true(这个只能关闭网页自身错误提示,要关闭警告框等看4楼)

  • Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)

  • pDisp.Document.parentWindow.execScript "window.alert=null;"

  • pDisp.Document.parentWindow.execScript "window.confirm=null;"

  • pDisp.Document.parentWindow.execScript "window.showModalDialog=null;"

  • pDisp.Document.parentWindow.execScript "window.open=null;"

  • End Sub

  • 警告框用上面关闭,代码要放在WEBBROWSER里面。
    弹出窗口的内容也是提交表单后服务器的返回值,不需从警告窗口的内容中取出,从服务器返回信息中截取提取即可。