PROCEDURE BeforeNavigate2 LPARAMETERS pdisp, url, flags, targetframename, postdata, headers, cancel IF LEFT(UPPER(m.url),4)="VFP:" m.Cancel = .T. && Stop WebBrowser from continueing after method ends. m.url = ALLTRIM(SUBSTR(m.url,5)) &url ENDIFNow to use this with the OnClick event on the HTML page.
<A HREF="" ID=CMD NAME=CMD></A>It will not be visible to the user.
<Span OnClick="javascript:CMD.href='VFP:MessageBox([That felt good.])';CMD.click();">Click Me</a>Now, when the user clicks the "Click Me" on the page, the CMD's Href is change to the "VFP:..." statement, and then the CMD tag is clicked. This calls the BeforeNavigate2 event, and the VFP code is executed.