Webbrowser troubles.

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

Webbrowser troubles.
  1. Unread #1 - Jun 6, 2007 at 9:54 PM
  2. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    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 :)
     
  3. Unread #2 - Jun 6, 2007 at 10:10 PM
  4. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    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
     
  5. Unread #3 - Jun 7, 2007 at 9:27 PM
  6. hmm
    Joined:
    Jan 21, 2007
    Posts:
    181
    Referrals:
    2
    Sythe Gold:
    5

    hmm Active Member

    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
     
  7. Unread #4 - Jun 10, 2007 at 1:56 AM
  8. Orii
    Referrals:
    0

    Orii Guest

    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 >

Users viewing this thread
1 guest


 
 
Adblock breaks this site