FileMaker and WebViewer communication
Here an overview:
Load webpage into WebViewer:
- Use FileMaker's Set Webviewer Script Step to pass in URL with content.
This is limited to a few thousand characters and URL may get logged. - Write local HTML file and call Set Webviewer Script step with an URL pointing to the file. Path.FilePathToFileURL may help here.
- Use WebView.LoadHTML in MBS Plugins to load HTML from text in variable or field.
- Use WebView.LoadURL to load URL.
Pass for Mac and iOS the cache policy and the timeout value.
Calling JavaScript:
- You can use MBS Plugin WebView.RunJavaScript which will pass the javascript to run. For Mac and iOS, this function returns the result, while on Windows, we can't get the result.
- Use WebView.RunJavaScriptReturnTitle which is designed to return the title of the document. In JavaScript you can put result in document.title and we pass it back. This may not work well with line breaks.
Pass data to JavaScript:
- Pass as parameter with JavaScript call above directly.
- Use a hidden textarea form field to fill with WebView.SetFormTextAreaValue.
This allows to easily pass text in any length. - Set form fields with WebView.SetFormInputValue and similar values
- Set title of document with WebView.SetTitle
Trigger Script from JavaScript:
- Use fmp URL to trigger a script. May run the wrong version of FileMaker.
- Use Webview.AddScriptMessageHandler to trigger script from JavaScript for FileMaker 16 and newer with Mac & iOS
- Use WebView.InstallCallback to trigger script for FileMaker 15 and earlier on Mac and Windows with IE 9 or older.
- Use ServerSocket.Start to listen to requests and send HTTP Request via XMLHttpRequest in JavaScript.
- Use Data API on FileMaker Server via requests sent from JavaScript.
Pass back data from JavaScript:
- Use a hidden textarea form field to fill with WebView.SetFormTextAreaValue.
This allows to easily pass text in any length. - Pass data with callbacks above.
- Query form fields with WebView.GetFormInputValue and similar functions
- Get live text of web viewer with WebView.GetPlainText function.
- Get live html text from web viewer with WebView.GetHTMLText functions.