New Window

i am making a browser in vb 2005 beta but sometimes when i click a link it opens in a new window in Internet Explorer now how can i have it so it opens in a new version of my own browser or a browser on a second form ?

any help would be greatly apreciated.

[265 byte] By [CyberOps] at [2008-2-21]
# 1
Hi,
You could try handling the NewWindow event of the webbrowser control...

cheers,
Paul June A. Domag

PaulDomag at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
ok im kinda new to this all so how whould i do that in vb 2005 beta 2 since the old way in vb 6 wont work anymore ?
CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
Hi,
To add a Event in a control, select the control, goto properties window, press the lightning button on the top. That will list the available events in the control...
Just DoubleClick on the textbox to add a defaultname event, or you could simply specify one...
cheers,
Paul June A. Domag
PaulDomag at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Ok so far i have accomplished that but i mean the code used for VB6 wont work, it doesnt stop IE from opening in a new window
CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
Hi,
Could you try posting the code?
Coz vb6 code normally wouldn't run on vb.net there are some conversions to be done...
cheers,
Paul June A. Domag
PaulDomag at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
This is the code im using now and it doesnt work it still opens IE in a new instead of using my own browser screen

Private Sub WebBrowser1_NewWindow2(ByVal ppDisp As Object, ByVal Cancel As Boolean)

Cancel = True

End Sub

CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7

This looks like VB6 code. Here is what the .NET code should look like, assuming the webbrowser control is named WebBrowser1...

Private Sub WebBrowser1_NewWindow(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
MessageBox.Show("NewWindow event.")
e.Cancel = True
WebBrowser1.Navigate(WebBrowser1.StatusText)

End Sub

The trick is, the event args don't provide the Uri to which the new window is navigating, so you can cancel the NewWindow, but then what? I used the StatusText in this snippet. When you mouse over links, the StatusText contains the href for the link. I wouldn't rely on this, however, because this won't work for javascript Open client-side script.

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 8
Ok this works great now indeed the problem is with the javascript , i removed messagebox.show because it's not really needed now is there a possibility around the status text that pops up with javascipt links ? and how can i set it that with the right mouse button click open in new window it will acutlly open in lets say form4 and the browser on that form ? i hope you understand what im trying to do here.
CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 9
Look here for details: http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=7228

What you need is an extended NewWindow event, that provides the Url. This post contains code to do that.

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 10
I already tried that but it didn't work for me as it started opening in IE again. Do you have another solution to just close the screen that popups saying there is a javascript blah blah blah. It would be good enough if it would simply automaticly close that screen.
CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 11

Just to be clear, you used the extended NewWindow event, grabbed the Url it was going to open, cancelled the event, and then launched a new instance of your browser application passing in the Url?

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 12

i used everything it said there, but are you saying i only should use a part of the code ?

Another option for me would be like i said an option close the popup warning automaticly.

CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 13
So what if you use the entire code on that site, does it then still not work on your particular computer?
HenrikDahl at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 14
that is what i did i tried everything and nothing
CyberOps at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...