« Dash help archives fo… | Home | How FileMaker.Perform… »

Working with Webkit Message Handlers in FileMaker

You may know that we added our script message handler functions in version 8.0 about two years ago. The feature was brand new in WebKit and you could use our WebView.AddScriptMessageHandler function to install a callback in the web viewer.

Fast forward to FileMaker 19, the same technique is used by Claris to provide the FileMaker.PerformScript function for MacOS and iOS. And with our plugin functions can we manipulate this and control whether it works or not.

If you look into the FileMaker.PerformScript function (see blog post The FileMaker.PerformScript function in FileMaker 19), you can see the message handler is named "fm". And this handler can be removed if needed with WebView.RemoveScriptMessageHandler function. If needed you can disable the feature once you don't need it any more. Or if the website you load is not trusted and you want to prevent it to trigger FileMaker scripts.

To restore the message handler, you can use WebView.AddScriptMessageHandler with name "fm". In next 10.3pr2 plugin we added a check there, so if you use that name, we restore the default FileMaker handler and not ours.

If you like to check whether the FileMaker.PerformScript function is ready, you can check with a call to WebView.Evaluate:

MBS( "WebView.Evaluate"; "web"; "typeof(FileMaker)")

This returns "object" if the object exists or "undefined" if not. By default FileMaker installs the FileMaker object once the page is loaded. We recommend putting in an "about:blank" as URL into the web viewers on the layout to make them be initialized earlier before you may set an URL in a script. Unless an URL is loaded into a web viewer, it is non existent and all plugin functions can't find it. Claris FileMaker Plugin
05 06 20 - 12:15