We help IT Professionals succeed at work.

webbrowser control?

bladefist
bladefist asked
on
198 Views
Last Modified: 2010-05-03
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
Comment
Watch Question

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

Author

Commented:
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...

Author

Commented:
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?

Author

Commented:
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

Author

Commented:
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?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.