Adblock breaks this site

Webbrowser troubles.

Discussion in 'Programming General' started by Covey, Jun 6, 2007.

  1. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Webbrowser troubles.

    How do i stop the webbrowser redirecting to Runescape.com when i try to go to the worlds?

    It doesn't seem to have a beforenavigate sub.
    I've tried the "navigating" sub but:
    Code:
    if e.url = "http://www.runescape.com" then
    e.cancel = true
    end if
    doesn't seem to work (it gives some error) :O

    Also i saw dodge post this but don't quite understand how to use it:
    Code:
    Dim Webpage As AxSHDocVw.AxWebBrowser = New AxSHDocVw.AxWebBrowser  'create new browser instance
            AddHandler Webpage.BeforeNavigate2, AddressOf Me.Webpage_BeforeNavigate2
            AddHandler Webpage.NavigateComplete2, AddressOf Me.Webpage_NavigateComplete2
            Webpage.RegisterAsBrowser = True
            Webpage.Silent = True
            Webpage.Visible = True 
            Webpage.Navigate("URL")
    EDIT
    im gonna probably be posting alot of simple fix questions because im starting in .net now :)
     
  2. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Webbrowser troubles.

    Figured it out
    Code:
    Private Sub webMain_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles webMain.Navigating
            If e.Url.OriginalString = "http://www.runescape.com" Or e.Url.OriginalString = "http://www.runescape.com/" Then
                e.Cancel = True
            End If
        End Sub
     
  3. hmm

    hmm Active Member

    Joined:
    Jan 21, 2007
    Posts:
    181
    Referrals:
    2
    Sythe Gold:
    5
    Webbrowser troubles.

    yea, didnt know that one, thanks..
    Code:
    If e.Url = New Uri("http://www.runescape.com/") Then e.Cancel = True
    
    that works too..got it from flamingidiots i think
     
  4. Orii

    Orii Guest

    Referrals:
    0
    Webbrowser troubles.

    Makes sense.
    The web browser control doesn't use the string datatype- uses the URI (Uniform Resource Identifier).

    'System.Uri is a much safer way of storing URIs. Extensive manipulation of URI related data using plain strings has been shown to cause many security and correctness problems.'

    As you have already solved your problem, I'm just explaining it.
     
< How do you add an existing User Control? | Simple Problem >


 
 
Adblock breaks this site