Resolved How to disable hyperlinks in WebBrowser?

iambowling247

New member
Joined
Aug 7, 2009
Messages
2
Programming Experience
Beginner
Hi, I am extremely new to Visual Basic, and I have only so far made an e-mail sender and an SMS sender (through e-mail).

So I am having troubles, I made a quick Web browser that I only want to show one page when you press a button ( you have to enter a name into a textbox and it will then make the URL to show), but the page has some links on it, which I don't want people to click on. I came up with a couple of solutions to my problem, which I don't even know if some of them are possible...
1) Disable the hyperlinks
2) Disable left clicks in the browser
3) Make the browser somehow only visible and not actually interactive with a mouse

I honestly have been searching for hours for a solution and also trying different things, but to no avail.

So my question is are any of those three options possible? If not then what is an alternative? If so then which would be easiest and how would I go about doing so?

Thanks for your time.

Here is what I have in total:
Code:
Public Class Form1
    Private Sub TextBox1_keypress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) = Keys.Enter Then
            WebBrowser1.Navigate("http://firstpartoftheURL/" + TextBox1.Text + "secondpartoftheURL.html")
            e.Handled = True
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("http://firstpartoftheURL/" + TextBox1.Text + "secondpartoftheURL.html")
    End Sub

End Class
I tried something like
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.AllowNavigation = True
        WebBrowser1.Navigate("http://firstpartoftheURL/" + TextBox1.Text + "secondpartoftheURL.html")
        WebBrowser1.AllowNavigation = False
    End Sub
Which I assumed would allow navigation once you clicked the button, but would then not allow it once you are done clicking it, but it just stays at false.
 
Last edited:

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,333
Location
Norway
Programming Experience
10+
  1. You were on track, but wait to set AllowNavigation property to False to the DocumentCompleted event.
  2. isn't this the same?
  3. right click menus you mean? IsWebBrowserContextMenuEnabled Property
 

iambowling247

New member
Joined
Aug 7, 2009
Messages
2
Programming Experience
Beginner
-EDIT-
My problem has been resolved, it was as simple as putting the WebBrowser in a panel and disabling the panel...
 
Last edited:
Top Bottom