Web Browser Popups

Hello everybody,

I have created a successful webbrowser in VB Express Edition 2005, with all controls (back, forward, stop etc..). Yet when a link is clicked which opens a new window on a website, it always opens in internet explorer...
how can I prevent this from happening?

Thankyou

BenBig Smile

[404 byte] By [Benjamino] at [2007-12-24]
# 1
im only assuming here so please someone correct me if im wrong but im thinking that this may be because your default browser is internet explorer, try changing this and get back to us Big Smile
Pace_uk at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Hi,
How can I change it, within my program there is no "change to default browser" button, and I have looken in Set access and defaults in windows, but nothing!!
Benjamino at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
It's not clear exactly what you want - are you saying that you want the link to open within your own webbrowser control instead of in a new window? Or are you trying to block it from opening at all?

Either way, you might look at the WebBrowser.Navigating event - you should be able to capture the URL that it is navigating to and cancel it, then if you want to open it inside your own webbrowser call the Navigate method and pass it the URL.

Or if you are saying that you want it to open in a different browser other than Internet Explorer, I don't believe that is supported.

Hope this helps,
Steve Hoag

shoagMSFT at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

hi,

I have this problem you said:

"you want the link to open within your own webbrowser control instead of in a new window"

I am new to this and just making the web browser as a getting started but i am having this problem how do I use the WebBrowser.Navigate event what do i need to type and where? please help!

Thanks in Advance

Luke

Lukeyboy at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5

wb.navigate(http://microsoft.com) '<-- Navigate property

This needs to be in an executable pathway (routine, procedure, property, or method).

Does this make sense?

The event occurs asynchronously after the browser had navigated. It is not essential that you do anything in the event.

You may want to do something when the page is full loaded when correspnds to

documentcompleted event?

What goes there? Whatever processing your application needs to do when a page has fully downloaded.

In some applications that may be nothing at all.

ReneeC at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6
I understand that but what I am have the problem is when a link is pressed on the web it opens in Internet Explorer, I dont put the link in for it to navigate to the webbrowser. What line of code do I need?

As you can tell im a n00b to this!

Thanks so far,
Luke.

Lukeyboy at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 7

If you simply want to block links from opening in a new window, you can use WebBrowser's NewWindow event:

Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow

e.Cancel = True

MsgBox("A Popup has been blocked")

End Sub

If you want to capture the link and open it in your own WebBrowser instead, that's a different story.

Hope this helps,

Steve Hoag

Visual Basic Express

shoagMSFT at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 8
sorry if im confusing but

I want to capture the link and open it in your own WebBrowser please help i've already said this but i am a n00b to this

Lukeyboy at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 9

i have the same problame

please help us

thanks

dhavalvyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 10
Yeah I need help with this to. Please help!
sticksnap at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 11

OMG!!! I just solved all of our problems by logics! observe

Private Sub WebBrowser1_NewWindow(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow

e.Cancel = True

MsgBox("You are now opening a link in a new window")

Dim nw As Form1

nw = New Form1

nw.Show(e)

End Sub

Observe the code. The variable "e" stands for the link's URL. I simply told my application to open up a new window(nw = New Form1) and then I told it to show "e" (the links url).

sticksnap at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 12

it is still not working.

the link is still opening in internet explorer

please check our code.

thanks

dhavalvyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 13
Darn! You are right. It didn't work. I have been trying to solve this for weeks now! Somebody please help us!
sticksnap at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 14

Mean while... I have some nice codes that I have created.

Web Browser Title, make url show up on address bar, and progress bar...

1. Make a new textbox...name it TextPrecentage(this will be the %age of the progress of your web browser)

2. Make a new progress bar... name it ProgressBar1

3. Make sure TextBox1 is your address bar. If it is not, than change "TextBox1" to the address bars name in the following code...

Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged

On Error Resume Next

Me.Text = "Web Browser" & " " & "[" & WebBrowser1.Document.Title & "]"

ProgressBar1.Visible = True

TextPrecentage.Visible = True

TextBox1.Text = WebBrowser1.Document.Url.AbsoluteUri

Dim d, t As Integer

d = e.CurrentProgress

t = e.MaximumProgress

TextPrecentage.Text = (ProgressBar1.Value / ProgressBar1.Maximum) * 100 & "%"

If d <= 0 Then

ProgressBar1.Value = 0

ProgressBar1.Visible = False

TextPrecentage.Visible = False

Else

ProgressBar1.Value = Math.Min(ProgressBar1.Maximum, Convert.ToInt32(Math.Floor(ProgressBar1.Maximum * (d / t))))

End If

End Sub

sticksnap at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...