Just wonder if you could help.
Basically I have a little project to finish, I have created a web browser with VB.NET, when I navigate let's say Google.com, I click to open a link on Google's website and it opens in a new page which is fine but the TextBox on my project (where the URL goes) does not appear any URL to which page/website I've gone to.
Can someone help me on this please?
Thank you so much!
Marco
You can do this by adding a handle to the Navigated event of the WebBrowser.
Private Sub WebBrowser1_Navigated(sender As System.Object, e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
Me.TextBox1.Text = Me.WebBrowser1.Url.ToString()
End Sub
The WebBrowser.Navigated Event is raised when the control has navigated to a new document and has begun loading it.
Related
I am making a VB.Net web browser, and to make the whole thing look nice, when the user right clicks, I want a groupbox to show up where the mouse was right clicked. I am using the ChromeWebBrowser.Net project on SourceForge and when I add the following code:
Private Sub ChromeWebBrowser1_MouseUp(sender As Object, e As MouseEventArgs) Handles ChromeWebBrowser1.MouseUp
If e.Button = Windows.Forms.MouseButtons.Right Then
GroupBox1.Location = (e.Location)
GroupBox1.Visible = True
Else
End If
End Sub
It should be working, but when I test it and right click on the web browser control, it does not show up. When I add the same code to the main forms code, it works fine, it just is not working on the browsing control. No errors or anything, it will just not show up. Is there something special I need to do, or can there be a workaround to this?
Thanks so much!
Honestly, this sounds more like you should be using a ContextMenuStrip. You can drop one onto your form(then add items to it), and finally after that you can set the webbrowser's contextmenustrip property to be the one you just designed.
I'm programming with vb.net 2012 and I'm having an issue with the WebKit.Net framework.
After my webkitbrowser object has loaded a page, I enter in login credentials, now the tab button gets hooked fine but when I hit enter (like people normally do on websites to login rather than actually hitting the login button) it keeps focus on another form object (tab index 0) and hits enter on that, it doesn't hook the enter button to the webkitbrowser.
I have added the following but it hasn't worked.
Private Sub WebKitBrowser2_MouseClick(sender As Object, e As MouseEventArgs) Handles WebKitBrowser2.MouseClick
Me.WebKitBrowser2.Focus()
End Sub
I'm hoping someone has a solution to this issue?
I am programming in Windows Mobile SDK 6 using Visual Basic, i would like to know how to make a button open the smartphone browser with a specific website path (make a link)
I got to the next piece of code so far:
Public Class GuitarHelperPage
Public link As New WebBrowser
Public adress As Uri
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
adress = New Uri("https://www.google.com")
Try
link.Navigate(adress)
'link.Focus()
Catch ex As System.UriFormatException
Return
End Try
End Sub
(the commented 'link.Focus()' its just something i tryed out, but i got the same output)
I simply want to click the button and open the browser at google homepage. But when I click it, the warning "This page contains both secure and nonsecure items. Do you want to continue?" appears and when I click "yes", nothing else hapens.
I've been researching and found this on MSDN help pages:
"The WebBrowser class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute"
SO i added this my main method:
<STAThread()> _
Shared Sub Main()
But still i get this error : "Type STAThread is not defined." And can't find a away around, I tried to add this same attribute to a Windows Desktop VB project and it works, maybe there is another way to do it in Mobile?
I am using .Net Framework 3.5 and windows mobile sdk 6.0 for this project
Please help, thank you.
If you want to open the default browser, you don't need a WebBrowser control. Just use the Process class, specifically the Start overload that takes in a ProcessStartInfo. Set the UseShellExecute property of the ProcessStartInfo to true so that it will open the default browser (e.g. if the user installed Opera Mobile, it will use that, not just always force IE).
I'm trying to build a simple desktop application to keep users on a certain website. It's very simple, just a webbrowser control with right click disabled. However certain applications on our website require popup windows and those windows always open up a full browser window.
Private Sub WebBrowser1_NewWindow(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
'What will the URL of this new window be?
Console.WriteLine("New Window maybe to " & WebBrowser1.Url.AbsoluteUri)
End Sub
Catching the newwindow event seems straight forward, but the event does not specify the URL that is being passed to the new window. I have seen some mention of a "NewWindow2" event, but vb.net does not appear to have anything like that.
How can I get the URL that is about to be opened in a new window?
The link is generated from a normal web application and not through a webbrowser.navigate call so it could be just about anything.
Thank you
You can catch the NewWindow2 event, create a new browser instance, host it in a new form or tab and pass it to ppDisp, then handle BeforeNavigate2 to get the new url. You can cancel the navigation if necessary. See Handle the BeforeNavigate2 event in the new window to get the url. for details.
I'm trying to load up a YouTube page using Visual Studio 2008 and a very simple Visual Basic project that contains just a WebBrowser. I want to load the page when the form loads:
Private Sub Form1_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
WebBrowser1.Navigate("http://code.google.com/apis/youtube/js_example_1.html")
End Sub
Every now & then (occurs once every 3-5 times, but varies), the form just shows a blank white box.
Could someone help me understand why this happens please.
Edit: This 'freeze' happens for any page, such as http://www.google.com. Is my WebBrowser control broken? Only seems to happen when i place the navigate code in the Form Load event, hmmm strange.
This is probably (almost certainly) happening because a form's Load event occurs before its first Paint event, so once in awhile the WebBrowser finishes navigating to Google (or wherever) before the form paints itself the first time, and thus the WebBrowser shows up as just a white box.
A very simple solution to this problem is to just put a Timer control on the form with a short Interval (say, 100 ms), set Enabled to true, and in its Tick event disable the Timer and then call Navigate(...) on your WebBrowser.