|
-
Jun 27th, 2011, 02:55 PM
#1
Thread Starter
Member
How do you make the webbrowser visit more than one page?
For example I want it to go to one page then when it finishes loading go to another. So I want to to go one from one from one all with the click of a button. Is this possible?
P.S: Another question, just to kill two birds with one stone, how do I make it so whatever is written in a textbox is added to the browser url. For example if the users write 'xyz' that it will add it to Google.com/ as an example and make it Google.com/xyz?
-
Jun 27th, 2011, 03:35 PM
#2
Fanatic Member
Re: How do you make the webbrowser visit more than one page?
Imagine WebBrowser1.Url was "www.google.com" and textbox1 text was "/youtube"
VB.NET Code:
WebBrowser1.Url += TextBox1.Text
webbrowser1.url would be "www.google.com/youtube"
Last edited by Emcrank; Jun 27th, 2011 at 04:19 PM.
-
Jun 27th, 2011, 03:57 PM
#3
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Thank you for answering the second question do you know the answer for the first?
-
Jun 27th, 2011, 04:26 PM
#4
Fanatic Member
Re: How do you make the webbrowser visit more than one page?
Have something like this
Code:
'DECLARATIONS:
dim I as Integer = 0
'-----------------------------------------
'WEBBROWSER1 DOCUMENT COMPLETED
I = + 1
'-----------------------------------------
'BUTTON 1 CLICK
If (I = 0) Then
WebBrowser1.Navigate("www.google.com")
ElseIf (I = 1) Then
WebBrowser1.Navigate("www.youtube.com")
EndIf
-
Jun 27th, 2011, 04:32 PM
#5
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Can you reexplain the second part? How can I incorporate question 1 and 2?
-
Jun 28th, 2011, 02:51 AM
#6
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Sorry it didnt work. When I click the button it goes straight to youtube, not first google then when it finishes loading to youtube. Any workarounds?
-
Jun 28th, 2011, 03:13 AM
#7
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Also when I try to add " WebBrowser1.Url += TextBox1.Text " it gives me an error that says: Operator '+' is not defined for types 'System.Uri' and 'String'.
-
Jun 28th, 2011, 03:42 AM
#8
Re: How do you make the webbrowser visit more than one page?
 Originally Posted by kytro360
For example I want it to go to one page then when it finishes loading go to another. So I want to to go one from one from one all with the click of a button. Is this possible?
P.S: Another question, just to kill two birds with one stone, how do I make it so whatever is written in a textbox is added to the browser url. For example if the users write 'xyz' that it will add it to Google.com/ as an example and make it Google.com/xyz?
I'm confused about the button. You want to move on to next page when the first page has finished loading OR when the button is clicked?
-
Jun 28th, 2011, 04:16 AM
#9
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Ok when they click the button I want it to go to one site then when it finishes loading the page it will visit another and vice versa. Also there will be a text box next to the button where try fill out there site ad the URL that the button visits will have the URL plus whatever they wrote in the text box as the web address
-
Jun 28th, 2011, 05:04 AM
#10
Re: How do you make the webbrowser visit more than one page?
vb.net Code:
Dim isMainUrl As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click isMainUrl = True WebBrowser1.Navigate("http://www.google.com/") '' or whatever End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then If isMainUrl Then isMainUrl = False WebBrowser1.Navigate(WebBrowser1.Url.AbsoluteUri & TextBox1.Text) End If End If End Sub
-
Jun 28th, 2011, 06:06 AM
#11
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Thx for the code Pradeep but will it work for my first question about the webbrowser visiting more than one site?
-
Jun 28th, 2011, 06:10 AM
#12
Re: How do you make the webbrowser visit more than one page?
 Originally Posted by kytro360
Thx for the code Pradeep but will it work for my first question about the webbrowser visiting more than one site?
yes
.
-
Jun 28th, 2011, 06:21 AM
#13
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
But in the code all I see is a spot for one URL?
-
Jun 28th, 2011, 08:24 AM
#14
Re: How do you make the webbrowser visit more than one page?
That's what you need for what you are telling till now.
1. Browse to a url.
2. Append the textbox text to that url and browse to this new url.
That's all.
-
Jun 28th, 2011, 09:16 AM
#15
New Member
Re: How do you make the webbrowser visit more than one page?
Hi, thanks Pradeep1210 i needed that code too thanks 
I did a little noob modified code from yours for navigate a listbox, is incomplete but this can help to the user that did the question :
Code:
Dim isMainUrl As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
isMainUrl = True
WebBrowser1.Navigate(textbox1.text) '' or whatever
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
If isMainUrl Then
isMainUrl = False
TextBox1.Text = (ListBox1.Items(ListBox1.SelectedIndex).ToString)
WebBrowser1.Navigate(TextBox1.Text)
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
Button1.PerformClick()
End If
End If
End Sub
-
Jun 28th, 2011, 10:56 AM
#16
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Hey Carlos will your code work or example if I have the sites in a list box and it visits all the sites in the list?
-
Jun 28th, 2011, 11:02 AM
#17
New Member
Re: How do you make the webbrowser visit more than one page?
Yes it will
You only have to select the first item(url) in the listbox then press the button and automatically it will visit each one, the code have bugs for example, you need to select the fist item int he listbox or when the listbox get empty will give you an error.
Try it ^^
PD:Sorry for my english im a spanish guy D:
-
Jun 28th, 2011, 11:12 AM
#18
Thread Starter
Member
Re: How do you make the webbrowser visit more than one page?
Sweet thanks Carlos I think your code will help a ton in my project. Also I wanna add a label that changes to success if the page was successfully loaded or failed if it didn't work. Should I add if then statements?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|