Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.3   8.4   8.5   9.0   9.1   9.2   9.3   9.4   9.5   10.0    Statistic  

WebView.Evaluate

Evaluates a JavaScript expression.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Webview 10.0 Yes Yes No No Yes
MBS( "WebView.Evaluate"; WebViewerRef; Expression )   More

Parameters

Parameter Description Example value
WebViewerRef Either the Web Viewer Object Name or the Web Viewer ID as returned by "WebView.FindByName" function.
Expression The JavaScript expression to evaluate. "1+"

Result

Returns value or error.

Description

Evaluates a JavaScript expression.
In contrast to WebView.RunJavaScript this function returns the result on Windows, but needs IE 9 or newer.
Use WebView.SetInternetExplorerVersion to configure the IE version used in web viewer.

For MacOS and iOS this passes through to WebView.RunJavaScript function.

Returns result on MacOS/iOS if possible in original data type, so numbers and booleans are returned as number and not as text. We try to return array or objects as JSON.
On Windows booleans and numbers are returned as numbers.

Examples

Evaluate an expression:

MBS( "WebView.Evaluate"; "web"; "1+2" )

Build some JavaScript object and return as JSON:

MBS("WebView.Evaluate"; "web"; "var obj = { name: \"John\", age: 30, city: \"New York\" };
JSON.stringify(obj);")

Defines and runs a function in JavaScript in the web viewer:

MBS("WebView.Evaluate"; "web";
"function makeCRCTable(){
                var c;
                var crcTable = [];
                for(var n =0; n < 256; n++){
                                c = n;
                                for(var k =0; k < 8; k++){
                                                c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
                                }
                                crcTable[n] = c;
                }
                return crcTable;
}

function crc32(str) {
                var crcTable = crcTable || (crcTable = makeCRCTable());
                var crc = 0 ^ (-1);

                for (var i = 0; i < str.length; i++ ) {
                                crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
                }

                return (crc ^ (-1)) >>> 0;
};

crc32('Hello World');")

See also

Example Databases

Blog Entries

Release notes

  • Version 10.0
    • Added WebView.Evaluate function to evaluate JavaScript expression and get back result for Windows.

Created 4th January 2020, last changed 15th January 2020


WebView.EstimatedProgress   -   WebView.ExecCommand

Feedback: Report problem or ask question.




Links
MBS FileMaker Plugins