Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4    Statistic  

WebView.AddScriptMessageHandler

Adds a script message handler.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
WebView 8.0 Yes No No No Yes
MBS( "WebView.AddScriptMessageHandler"; WebViewerRef; Name )   More

Parameters

Parameter Description Example value
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

Blog Entries

Release notes

Created 15th December 2017, last changed 4th June 2020


WebPolicyDelegate.RemoveMimeType   -   WebView.AddUserScript

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins