我用vb写了个浏览器,但是网页弹出的页面仍然是由IE显示的
如何让它弹出的页面仍然由我的浏览器程序显示啊 问题点数:100、回复次数:12Top
1 楼ZOU_SEAFARER(颓废程序员^_^)回复于 2006-03-10 11:40:45 得分 30
有两个事件与打开新窗口有关,NewWindow2和BeforeNavigate2事件。如果使用IE快捷菜单上的“在新窗口中打开”或将<a>的target设置为_blank打开新窗口,将触发NewWindow2事件, 如果是采用<A HREF=javascrpit:...>的方式打开新窗口,也可以利用WebBrowser控件的BeforeNavigate2事件:
Private Sub brwWebBrowser_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
参数URL是链接地址。
当用户点击时会发生这个事件,你可以设置Cancel = False来禁止IE打开新窗口,而自己打开一个窗口,显示URL指定的地址。
Top
2 楼ZOU_SEAFARER(颓废程序员^_^)回复于 2006-03-10 11:43:10 得分 20
如何将自己的浏览器定义为默认的
问题: 我用vb编写了一个浏览器,但如果一个连接是在新窗口打开,就是用的ie。我希望把我的浏览器注册成默认的浏览器,这样就可以解决。请问如何注册呢?谢谢
你只需要将自己的浏览器和htmlfile和http之间建立关联就可以了。你看一下注册表HKEY_CLASSES_ROOT下面http和htmlfile相关的键就可以了。
Top
3 楼chinagod(繁星)回复于 2006-03-10 12:45:18 得分 0
我的电脑没有msn,能不能实例介绍一下brwWebBrowser_BeforeNavigate2Top
4 楼chinagod(繁星)回复于 2006-03-10 12:45:56 得分 0
msdn,我说错了,我得机器没装msdnTop
5 楼zou19820704(天下英雄)回复于 2006-03-10 13:22:31 得分 20
英文说明:
Fires before a navigation occurs in the given object (on either a window or frameset element).
Syntax
Private Sub object_BeforeNavigate2( _
ByVal pDisp As Object, _
ByVal URL As Variant, _
ByVal Flags As Variant, _
ByVal TargetFrameName As Variant, _
ByVal PostData As Variant, _
ByVal Headers As Variant, _
ByRef Cancel As Boolean)
Parameters
object
Object expression that resolves to the objects in the Applies To list.
pDisp
Object that evaluates to the top-level or frame WebBrowser object corresponding to the navigation.
URL
String expression that evaluates to the URL to which the browser is navigating.
Flags
Reserved for future use.
TargetFrameName
String expression that evaluates to the name of the frame in which the resource will be displayed, or NULL if no named frame is targeted for the resource.
PostData
Data to send to the server if the HTTP POST transaction is being used.
Headers
Value that specifies the additional HTTP headers to send to the server (HTTP URLs only). The headers can specify such things as the action required of the server, the type of data being passed to the server, or a status code.
Cancel
Boolean value that the container can set to True to cancel the navigation operation, or to False to allow it to proceed.
Error Codes
No return value.
Remarks
Navigating to a different URL could happen as a result of external automation, internal automation from a script, or the user clicking a link or typing in the address bar. The container has an opportunity to cancel the pending navigation
Top
6 楼chinagod(繁星)回复于 2006-03-10 13:42:14 得分 0
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Cancel = False
End Sub
我想禁止弹出窗口,但是没用阿,我的浏览器里面显示的是新浪的主页Top
7 楼rainstormmaster(暴风雨 v2.0)回复于 2006-03-10 14:12:00 得分 20
处理NewWindow2事件了吗?Top
8 楼chinagod(繁星)回复于 2006-03-10 14:24:56 得分 0
NewWindow2?我没处理阿,谁能给个实例?我没装msdnTop
9 楼chinagod(繁星)回复于 2006-03-10 15:22:05 得分 0
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set ppDisp = WebBrowser1.Object
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Cancel = False
End Sub
在这个代码工作下,新窗口是不弹出来了,但是有的链接点击下会出错,有的则又正常。
而且在BeforeNavigate2中用什么代码打开一个新的自编窗口看网页阿Top
10 楼littleXX(游鱼)回复于 2006-03-10 15:22:48 得分 0
NewWindow2 才对头,BeforeNavigate2 没搞头Top
11 楼rainstormmaster(暴风雨 v2.0)回复于 2006-03-10 15:48:24 得分 10
建议看看这个:
http://community.csdn.net/Expert/topic/4232/4232137.xml?temp=.8207361Top
12 楼testoktest()回复于 2006-04-22 23:51:29 得分 0
markTop




