vb程序WebBrowser控件如何实现返回
当点击WebBrowser控件中网页的一个链接打开另一个网页,如何实现自动返回到前一个网页?即打开了另一个网页立即后退.当网址显示为http://www.163.com,...
当点击WebBrowser控件中网页的一个链接打开另一个网页,如何实现自动返回到前一个网页?
即打开了另一个网页立即后退.
当网址显示为http://www.163.com,立即返回到http://www.baidu.com,要怎样实现? 展开
即打开了另一个网页立即后退.
当网址显示为http://www.163.com,立即返回到http://www.baidu.com,要怎样实现? 展开
1个回答
展开全部
Private strurl As String
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)
If InStr(1, UCase(URL), "www.163.com") Then Cancel = True
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
If InStr(1, UCase(strurl), "www.163.com") Then Cancel = True '如果含http://www.163.com不弹出窗口
'下面语句是如果访问163,则转百度
'If InStr(1, UCase(strurl), "www.163.com") Then WebBrowser1.Navigate "http://www.baidu.com" '如果含http://www.163.com,本窗口访问百度
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
strurl = Text
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)
If InStr(1, UCase(URL), "www.163.com") Then Cancel = True
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
If InStr(1, UCase(strurl), "www.163.com") Then Cancel = True '如果含http://www.163.com不弹出窗口
'下面语句是如果访问163,则转百度
'If InStr(1, UCase(strurl), "www.163.com") Then WebBrowser1.Navigate "http://www.baidu.com" '如果含http://www.163.com,本窗口访问百度
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
strurl = Text
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询