« NSProgressIndicator w… | Home | HTMLViewer JavaScript… »

FileMaker and WebViewer communication

A lot of FileMaker developers love to interact with WebViewer. There are a couple of ways to move data in/out or call back to FileMaker. For a few things our plugin can help a lot.
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:

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:

If you know more to add here, please comment or email us.
24 08 18 - 09:14