Blocking URL

Add-in Express™ Support Service
That's what is more important than anything else

Blocking URL
 
Jeff Hafer




Posts: 12
Joined: 2010-09-21
Hello,

I'm trying to block browsing to certain URLs using the IEModule_BeforeNavigate2 event. However, I don't think I'm using the correct code to achieve this.

I have looked at some examples in the forum, but they have all been in C# and I'm using VB.Net:
http://www.add-in-express.com/forum/read.php?FID=10&TID=6647&MID=33120#message33120
http://www.add-in-express.com/forum/read.php?FID=10&TID=8885&MID=45384#message45384
http://www.add-in-express.com/forum/read.php?FID=10&TID=8411&MID=42651#message42651


Here's what I've got so far. My code does not prevent the browser from going to www.google.com. It gives no errors.:

Private Sub IEModule_BeforeNavigate2(ByVal e As AddinExpress.IE.ADXIEBeforeNavigate2EventArgs) Handles MyBase.BeforeNavigate2
If e.Url.ToString.IndexOf("www.google.com") > -1 Then
Dim pdisp As IE.WebBrowser = e.PDisp
pdisp.stop()
End If
End Sub

Any help would great. Thanks,
Jeff.
Posted 04 Aug, 2011 09:53:54 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Jeff,

A raw sketch:

Private Sub IEModule_BeforeNavigate2(ByVal e As AddinExpress.IE.ADXIEBeforeNavigate2EventArgs) Handles MyBase.BeforeNavigate2 

If e.Url.ToString.IndexOf("www.google.com") > -1 Then e.Cancel = True

End Sub 



Andrei Smolin
Add-in Express Team Leader
Posted 04 Aug, 2011 10:17:52 Top
Jeff Hafer




Posts: 12
Joined: 2010-09-21
Andrei,

You are a life saver! You solution worked perfectly.

Jeff.
Posted 04 Aug, 2011 10:29:06 Top