How to Block Pop Up with WebBrowser Control

iamblackhat

Registered Member
Joined
Feb 6, 2008
Messages
74
Reaction score
11
Hi guys, I'm trying to create a simple application using the WebBrowser control.

When I visit a certain website using the webbrowser control, a pop up window appears. Is there anyway to block this pop up using the WebBrowser control?
 
Code:
 If WebBrowser1.Url.ToString = "popup url" Then
            WebBrowser1.Navigate("destination url")
        End If
That's the most basic thing I cam up with in 30 seconds... If you're using C#, it shouldn't be too hard. You get the idea of what this does. You can expand on this a lot, but this is quite basic.
 
Firefox + "adblock+" + noscript = NO POPUPS

Not sure about code 4 u though.
 
Just saw this on vbforums.com:

Code:
Private Function IsPopupWindow() As Boolean

      On Error Resume Next

      If WebBrowser1.Document.activeElement.tagName = "BODY" Or WebBrowser1.Document.activeElement.tagName = "IFRAME" Then
   
      IsPopupWindow = True

      Else

      IsPopupWindow = False

      End If

      End Function

       

      Private Sub webbrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)

      Dim frm As Form1

      Cancel = IsPopupWindow

      If Cancel = False Then

      Set frm = New Form1

      Set ppDisp = frm.WebBrowser1.object

      frm.Show

      End If

      End Sub
 
Most peoples computers have a popup blocker anyway.

He's talking about a popup blocker for the VB.net WebBrowser control, it's a webbrowser itself, so it obviously won't use your own browser's popup blocker.

I'd use the code mentioned above :)
 
yup, the only simple way to block the popup from the WB control is thru NewWindow2 property (just put cancel=true)

but sometime, it can't block all the popup. dunno with the new version of IE. it all affected by the client's IE settings.
 
Back
Top