View Full Version : Calling JavaScript functions in a WebView section from Visual FoxPro

2012-10-06, 01:42
You can call JavaScript functions that you have in your WebViews and return the result back directly into your Visual FoxPro code. This allows you to interact directly with a WebViewWidget in Visual FoxPro.

Supposing you have a WebView section with the name "mywebview" and inside that you have a JavaScript function called "getMyData()" Just call it like this and Lianja will marshall the call and the result returned.

mydata = Lianja.getElementByID("mywebview").webview.evaluate("getMyData();")

You do exactly the same in Python, PHP or JavaScript code.

If you load the jQuery library into your WebView you can issue normal jQuery calls directly from Visual FoxPro, PHP, Python or JavaScript as well.

2012-10-06, 01:49
So now you may be wondering... Well ok, how do I call Visual FoxPro from within the actual WebView when lets say a jQuery event occurs.

Simple. Just like this inside your WebView HTML5/JavaScript.

var result = Lianja.evaluate("nameOfMyFunction()");

or alternatively execute a command:

var result = Lianja.execute("do somefilename with arg1,arg2,etc");
if (result != 0)
/* an error occurred */

So as you can see, there is a seamless integration that works both ways.