-
Jan 9th, 2015, 03:17 AM
#1
Thread Starter
Junior Member
Webbrowser cancel navigation
Hi
I have two Webbrowser controls on a form.
The first control loads and displays a page of links. I need to be able to click a link and have it open its page in the second control, but not the first control, which is its natural action.
I have tried Cancel = True in BeforeNavigate, but that prevents the links page from opening at all.
Does anyone have a better way to make this work?
Thanks.
-
Jan 9th, 2015, 04:11 AM
#2
Re: Webbrowser cancel navigation
Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum
-
Jan 9th, 2015, 12:17 PM
#3
Re: Webbrowser cancel navigation
Code:
Private WithEvents NewWebBrowserWindowHandler As SHDocVwCtl.WebBrowser_V1
Private Sub Command1_Click()
WebBrowser1.Navigate "www.vbforums.com"
End Sub
Private Sub Form_Load()
Set NewWebBrowserWindowHandler = WebBrowser1.Object 'Your webrowser control comes here..
End Sub
Private Sub NewWebBrowserWindowHandler_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
WebBrowser2.Navigate URL
'Tell the control, your code has processed the event,
'there's no need to open the new window
Processed = True
End Sub
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 3rd, 2018, 10:23 AM
#4
New Member
Re: Webbrowser cancel navigation
Originally Posted by jmsrickland
Code:
...
Processed = True
End Sub
This is an old thread (but not compared to most VB6 threads), but I was scouring the Web for help with the same problem.
At first glance, I didn't understand how "Processed = True" on its own could do anything. As far as I could tell, "Processed" is some undeclared variable. But I tried it anyhow and sure enough, it didn't do anything. What am I missing there?
Anyway, my problem came when I was intercepting the call to open the file in BeforeNavigate2 (an odd name since there is no BeforeNavigate1 that I can find), calling a sub in my program to bring up the second WebBrowser and open the ULR in it, then using Cancel=True to keep the first browser from changing, but the program was locking up there until I did a Ctrl-Break and then it finished. Eventually, I tried adding
Code:
[2nd browser window].Refresh
DoEvents
Cancel = True
and it worked fine.
-
Sep 3rd, 2018, 10:24 AM
#5
New Member
Re: Webbrowser cancel navigation
Originally Posted by jmsrickland
Code:
...
Processed = True
End Sub
This is an old thread (but not compared to most VB6 threads), but I was scouring the Web for help with the same problem.
At first glance, I didn't understand how "Processed = True" on its own could do anything. As far as I could tell, "Processed" is some undeclared variable. But I tried it anyhow and sure enough, it didn't do anything. What am I missing there?
Anyway, my problem came when I was intercepting the call to open the file in BeforeNavigate2 (an odd name since there is no BeforeNavigate1 that I can find), calling a sub in my program to bring up the second WebBrowser and open the ULR in it, then using Cancel=True to keep the first browser from changing, but the program was locking up there until I did a Ctrl-Break and then it finished. Eventually, I tried adding
Code:
[2nd browser window].Refresh
DoEvents
Cancel = True
and it worked fine.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|