Link to home
Start Free TrialLog in
Avatar of bladefist
bladefist

asked on

webbrowser control?

Hi I am making a visual basic application to generate html code, and then display it in a webbrowswer control, or suggest another control if you know of a better one. At any rate, when the user clicks on a link, is there anyway to have visual basic catch that link? so basically i will have a link that will act as a command button sort of, and I would like to be able to store data in side the html for the link...so i would like to be able to extract that as well
Avatar of YohanShminge
YohanShminge

The webbrowser control should work fine.  Just browse to the local file you create with your prog.  Where will the user click on this link? Within your program? If it is outside of your program, I dont think you can detect it.  Otherwise, you could make a label that acts as a hyperlink using the Label1_Click event.  Could you clarify "store data inside the html for the link" please?  Are you talking about searching an HTML document for links?
Just do this...use the BeforeNavigate2() it will get called when a user clicks a link or is changing sites....

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)

MsgBox URL
End Sub
Avatar of bladefist

ASKER

in the href of the link, you can specify a name=

where you can put like. name="year2004" and then when they click on the link, you can pull the data from the name value, to use w/ sql lines or whatever you want. I would need to pull in that name data
Ok, so basically a query string, kindof like when you search google:
http://www.google.com/ ***search?hl=en&ie=UTF-8&oe=UTF-8&q=yeah***

Now is this HREF going into your program or are you writing some CGI or something?  Please explain...
when i click on the link, I want to be able to pull the properties of the link into VB
Yes but WHERE are you clicking the link? In the Webbrowser control?
yes
OK, then you can get the URL the user clicked on by the WebBrowser1.LocationURL property, but this is only set after the NavigateComplete2 event, in which you can catch the URL:

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim linkClicked as String
linkClicked = URL
End Sub
not to be rude or anything, but BrianGEFF719 already said that, and it wasnt what i was quite looking for.
Aha, you are quite right! (Pardon my forgetfulness) So then what exactly are you looking for?
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial