zoukankan      html  css  js  c++  java
  • WebBrowser取消弹出式窗口、忽略错误

    代码
     1 WebBrowser取消弹出式窗口
     2 
     3 Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant) 
     4 Dim oDoc1 As HTMLDocument 
     5 Set oDoc1 = pDisp.Document 
     6 oDoc1.parentWindow.execScript "function alert(){return;}" 
     7 oDoc1.parentWindow.execScript "function confirm(){return;}" 
     8 oDoc1.parentWindow.execScript "function showModalDialog(){return;}" 
     9 End Sub
    10 
    11 
    12 '忽略错误
    13 Private Sub WebBrowser1_DownloadBegin() 
    14 WebBrowser1.Silent = True 
    15 End Sub 
    16 
    17 Private Sub WebBrowser1_DownloadComplete() 
    18 WebBrowser1.Silent = True 
    19 End Sub
    20 
    21 
    22 某些网页出于各种考虑会弹出对话框要求信息确认,往往会中断我们的webbrowser过程,可以使用如下方法:
    23 1.加入Microsoft Html Object
    24 2.加入语句
    25 
    26 Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    27 Dim obj As HTMLDocument
    28 Set obj = pDisp.Document
    29 obj.parentWindow.execScript "function showModalDialog(){return;}" '对showModalDialog引起的对话框进行确定
    30 End Sub
    31 而confirm引发的对话确定框可用confirm替换showModalDialog即可,Alert等同理~
    32 
    33 另一种方法在CSDN看到的方法,过个记录(未尝试)
    34 
    35 Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongAs Long 
    36 
    37 ShellExecute frmDisplay.hwnd, vbNullString, "http://www.sina.com", vbNullString, vbNullString, SW_SHOWNORMAL
    38 
  • 相关阅读:
    Linux Shell 1>/dev/null 2>&1 含义
    iSCSI存储的3种连接方式
    Linux Shell远程执行命令(命令行与脚本方式)
    VIM常用命令
    RHEL6.2配置从零开始
    shell 正则表达式与文件名匹配
    Java中判断非空对象.
    Facebook的时序数据库技术(上)
    SpringBoot+SpringCache实现两级缓存(Redis+Caffeine)
    Swagger模型字段排序问题
  • 原文地址:https://www.cnblogs.com/xxaxx/p/1635298.html
Copyright © 2011-2022 走看看