Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
WebView.AddScriptMessageHandler
Adds a script message handler.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
WebView | 8.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |
MBS( "WebView.AddScriptMessageHandler"; WebViewerRef; Name ) More
Parameters
Parameter | Description | Example |
---|---|---|
WebViewerRef | Either the Web Viewer Object Name or the Web Viewer ID as returned by "WebView.FindByName" function. | |
Name | The name of the message handler. | "test" |
Result
Returns OK or error.
Description
Adds a script message handler.Adding a script message handler with name name causes the JavaScript function window.webkit.messageHandlers.name.postMessage(messageBody) to be defined in all frames in all web views that use the user content controller.
Only for FileMaker 16 and newer.
Trigger script in FileMaker from JavaScript:
window.webkit.messageHandlers.test.postMessage({'filename':'WebView Message Handler.fmp12', 'parameter':'Hello World from JavaScript', 'scriptName':'test'});
Evaluate expression in JavaScript:
window.webkit.messageHandlers.test.postMessage({'evaluate':'MBS( "Msgbox"; "Hello from Evaluate in JavaScript" )'});
Added iOS for version 9.5.
New in version 10.3: If you pass "fm" as name, we connect the standard FileMaker handler, so you can restore it after you removed it earlier with WebView.RemoveScriptMessageHandler function.
Examples
Add script handler:
Set Variable [ $r ; Value: MBS( "Webview.AddScriptMessageHandler"; "web"; "test" ) ]
Restore FileMaker 19 handler:
Set Variable [ $r ; Value: MBS( "Webview.AddScriptMessageHandler"; "web"; "fm" ) ]
See also
Release notes
- Version 9.5
- Added Webview.RemoveScriptMessageHandler and Webview.AddScriptMessageHandler for iOS.
Example Databases
Blog Entries
- Using PerformScript in a custom WebViewer in FileMaker
- How FileMaker.PerformScript triggers scripts
- Working with Webkit Message Handlers in FileMaker
- The FileMaker.PerformScript function in FileMaker 19
- Check out options for FileMaker JavaScript Integration
- Trigger FileMaker Scripts from JavaScript in FileMaker without fmp URL
- MBS FileMaker Plugin 9.5 - More than 5900 Functions In One Plugin
- MBS FileMaker Plugin, version 9.5pr8
- FileMaker and WebViewer communication
- Trigger FileMaker Scripts from JavaScript in FileMaker 16
This function checks for a license.
Created 15th December 2017, last changed 4th June 2020