CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    Internet Browser Advice (RESOLVED)

    Hey Yall'
    Ive created an internet Browser for my 8 year old but my next step is to filter what pages he goes on. I was thinking about creating some sort of database with authorized pages and have the browser do a check to see if it's in the list prior to displaying. I dont know if this will work and Im asking if anyone has done something similar or have a better way?

    Thanks
    Last edited by dedub; July 3rd, 2004 at 09:29 PM.
    R.L.T.W. A+, NET+, CCNA

    doin' my best

  2. #2
    Join Date
    Mar 2004
    Location
    UK
    Posts
    188
    Seems to be a good way of doing it although the database will need to be updated regularly and you will need to come up with an easy way of deleting dead links and uploading new ones easily. Could just be a comma seperated text file rather than an Access DB. Good luck with it.

    Nick

  3. #3
    Join Date
    Nov 2003
    Location
    Seattle, WA
    Posts
    265
    Yes your going the right direction. In fact i've written something like this before.

    Mines a bit more advanced then just a list of forbidden urls if you need help IM me and i'd be more then willing to help you out.

    Mine checks the database first for the url.
    If its not found then it will scan meta tags and page content to determine if the site is a valid ( clean ) site for a kid to view.
    And if its not it will add it to the forbidden url database.

    But simply URL blocking could be done like this..
    Code:
    Dim forbidden_urls() As String
    
    Private Sub Form_Load()
        ReDim forbidden_urls(1 To 2)
        
        forbidden_urls(1) = "http://www.yahoo.com/"
        forbidden_urls(2) = "http://www.google.com/"
        
        WebBrowser1.Navigate "http://www.google.com"
    End Sub
    
    Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
        If InDatabase(CStr(URL)) Then
            WebBrowser1.Navigate App.Path & "\forbidden.htm"
        End If
    End Sub
    
    Private Function InDatabase(ByVal URL As String) As Boolean
        For x = LBound(forbidden_urls) To UBound(forbidden_urls)
            If LCase(URL) = LCase(forbidden_urls(x)) Then
                InDatabase = True
                Exit Function
            End If
        Next
        
        InDatabase = False
    End Function
    Of course this is simple. In the real one you would integrate more complex url checking...
    "Lose it? It means go crazy...nuts...insane...bonzo...no longer in possession of one's faculties...3 fries short of a happy meal...WACKO!!!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured