Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Variable from VFP's Browser Control 1

Status
Not open for further replies.

Apata

Programmer
Apr 5, 2006
52
US
I need to get a variable to use in my table when a link is clicked in the Browser Control of my form. I'll appreciate to know the method to use to achieve this. If the method needs to be enabled, I would also like to know how to enable it programatically, so it is seamless and non-confusing to the user. Thanks.

Apata
 

apata,

It's not clear what variable you want to retrieve. In general, when the user clicks on a hyperlink, the browser loads a file or a URL. There are no variables involved.

Do you perhaps mean that you want to trap the click as an event?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike. What I mean is that if a user clicks a hyperlink instead of loading a file or a url I could extract the name of the link as a variable, or have a variable associated with the link, so that I could use that variable to process a table, etc.

Apata
 

Apata,

You need to trap with browser's BeforeNavigate2 method.

The method receives seven parameters. The second of these contains the URL that the user is trying to navigate to. That will tell you what the user clicked on.

To prevent them actually going to the URL, set the seventh paramter to .T.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike, the trapping seems to works fine. However, when I click on a link and do a wait window on its URL, it shows the URL as the file directory where the form is contained. Is there a way to get to the URL itself? Thanks.

Apata
 

Apata,

The URL parameter (second parameter) will contain whatever text appears in the href attribute of your hyperlink. That will usually be a URL or a full file specification.

It's difficult to answer your question without knowing more about your HTML. In particular, what is this form that you are referring to? Is if an HTML form, or a VFP form, or what?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I am using a VFP form. I placed the browser control on the form and an HTML page is loaded. On the HTML a reference is entered like this:
Code:
<a href="001">Pumsic Company</a><br>
But when I did a [red]Wait window[/red] command on the hyperlink [blue]Pumsic Company[/blue], it returned:

[highlight]C:\VFP Browser Test\001[/highlight].

This is the directory from where I am running the form joined with the ID. But all I want to get out is the ID, which in this case is 001. I can extract the ID out of this, but I am just wondering if it wouldn't just return the ID alone as the URL. Thanks.

Apata
 

Apata,

No, the web browser control won't return just the ID. The browser is only interested in fully-qualified file names.

As you probably know, the solution is to use the JUSTFNAME() function to find the ID.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike, what can I say? Thanks!

Apata
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top