on my WebBrowser I have a address bar of course, but I can only search urls in the address bar, like "facebook.com" and something. I want my address field to be able to work like a search engine to, so when I type like www.facebook.com I will go to facebook.com and when I search like facebook, without www or .com or something I want my address bar to redirect me to https://www.google.se/?gws_rd=ssl#q=facebook if you know what I mean.
相关问题
- What is the best way to do a search in a large fil
- 'System.Threading.ThreadAbortException' in
- how to use special characters like '<'
- TestCafe - The browser always starts in clean slat
- UrlEncodeUnicode and browser navigation errors
相关文章
You can try using this function::
Maybe this is not the best way but it works.
The only thing you need to do is add More things to the arrays to make it more prefect."because there are more possible web url endings and starts"
Dim CheckArrStart()
Dim CheckArrEnd()
I would make a function to check to check the url entered in the address bar.
Private Function CheckWebPageLink(ByVal Link As String) As Boolean
In this function i would use 2 for each loops to check the start en the end of the url.
If i find a start i would + 1 to my ok dim "Dim Ok As Integer = 0" and remove it from the string
Then go to the next for each loop to find a url end.
So if a find a end + 1 to my ok dim and also remove the end from the string. i do this because i want to check how long the string is at the end becaus there must be something between www. and .com
Then at the end of my function i check if my ok dim has a value of 2 and how long the link is without the start and the end.
If true i return a true boolean and if false i return a false boolean.
Then in my navigate button i make a if statement end check if the booblean from my function is true ore false."If CheckWebPageLink(ToolStripTextBox1.Text.ToLower) = True Then"
If true just navigate to the url and if false :
WebBrowser1.Navigate("https://www.google.com/?gws_rd=ssl#q=" & ToolStripTextBox1.Text)
Like i already said the arrays you still need to fix, i just added some to test.