在webBrowser控件中,我知道可以这么执行:
NavigateComplete2事件中加入:
brwWebBrowser.Document.parentWindow.execScript "window.open=null;"
这样子就可以对window.open方法进行了重写,
现在,我在下载使用vbMHWB这个控件,因为我要过滤图片下载,
而且我发现,如果在NavigateComplete2事件中加入:
brwWebBrowser.Document(iCur).parentWindow.execScript "window.open=null;"一运行后,系统会报错: 拒绝访问,然后停在这个命令行.请问,在vbMHWB这个控件中,我怎么才能做到对window.open(),window.focus()这类函数的重写?让访问的网页不执行,这些命令?哪个可以帮我一下,我已经转了快一个星期了,一直没有解决,GOOLE,都GOOLE了好多次了.
以下是我的控件的下载地址;
http://www.codeproject.com/atl/vbmhwb.asp

解决方案 »

  1.   

    Private Sub brwWebBrowser_DocumentCompleteWBEx(ByVal wbUID As Integer, URL As Variant, ByVal pDisp As Object, ByVal isTopLevel As Boolean, ByVal sDocSource As String) 'IE中DHTML的属性和方法可以重写。当然alert,confirm, showModalDialog也不例外。
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.alert=null;" '<------error here! access refuse 访问拒绝 
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.confirm=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.showModalDialog=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.showModelessDialog=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.open=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.focus=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window. &ouml;nunload=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.attachEvent=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "window.eval=null;"
    brwWebBrowser.Document(iCur).parentWindow.execScript "eval=null;" 
      

  2.   

    给你点意见:
    在http://www.mvps.org/emorcillo/en/code/vb6/index.shtml中可以找到定制WebBrowser的例子(注意看它的说明)
    这里面是个自定义的webbrowser控件(和vbmhwb.dll功能基本上相同,不同的是这个控件是用vb写的),看看人家是怎么封装的
      

  3.   


    谢谢.请问一个,webbrower加载工具条,怎么来实现?自动加载google,baidu这类的工具条.三天后结贴.
      

  4.   

    看看http://www.evict.nl/open_source.asp
    里面有几个优秀的关于WebBrowser的例子和Source Code。
      

  5.   

    我用VBMHWB 控件, 但是以下代码提示 document 参数不可选 , 楼主知道这是怎么回事吗?原代码是这样:Private Sub vbWB1_DocumentComplete(ByVal wbUID As Integer, URL As Variant, ByVal pDisp As Object, ByVal isTopLevel As Boolean)
    Dim a  For Each a In vbWB1.Document.getElementsByTagName("A")       MsgBox fastemaila.href
        Next
    End Sub