Transitioning scripts for WebView2
But if you urgently need to use one of our WebView functions, consider to change your scripts and use our plugin based web viewer. With the WebView.CreateWithControl function you can create an IE based web viewer on a layout and use our existing functions to do all the web viewer related functions:
Since FileMaker 19 introduced the "Perform JavaScript in Web Viewer" script step. You may use that where needed to replace a few of our functions. But since it just allowed to call JavaScript functions, you may need to be able to control the html and include the require functions.#create with control on window
Set Variable [ $$web; Value:MBS("WebView.CreateWithControl"; 0; "placeholder"; 1) ]
Set Variable [ $r; Value:MBS( "WebView.LoadURL"; $$web; "http://www.mbs-plugins.com") ]
Let's give you an example and change the TinyMCE example from us. We use here the WebView.SetFormTextAreaValue and WebView.RunJavaScript functions to pass text to the control. The form field is used to work around some limitations in the past on how much you can pass via URL or JavaScript calls. It still works well today:
Now to get this working with the script step, we have to define a JavaScript function to take the call. So we transform our JavaScript code above into a nice function called SetText and taking a single parameter named text:Set Variable [ $r ; Value: MBS( "WebView.SetFormTextAreaValue" ; "HTMLEditor"; "formtest"; "output"; $text; 0 ) ]
Set Variable [ $r ; Value: MBS( "WebView.RunJavaScript" ; "HTMLEditor"; "try { tinyMCE.get('elm1').setContent(formtest.output.value); } catch (e) { alert(e); }" ) ]
function SetText(text)As you see we include some exception handling, which may tell you if something is not working. Now we call it with the script step and pass our $text variable:
{
try
{
tinyMCE.get('elm1').setContent(text);
}
catch (e)
{
alert(e);
}
}
When you try this, you will notice it works just as fine as the existing calls with MBS FileMaker Plugin.Perform JavaScript in Web Viewer [ Object Name: "HTMLEditor" ; Function Name: "SetText" ; Parameters: $text ]
Update: We are working on a fix for our WebView functions to make them work for WebView2 controls on Windows.