Perform JavaScript in Web Viewer
Performs a JavaScript function in a web viewer.
Options
- Object Name is the name of the web viewer object. See Naming objects. If not specified, the active web viewer is used.
- Function Name is the name of the JavaScript function to perform. The name is case sensitive.
- Parameters are one or more optional text parameters to pass to the JavaScript function. Drag parameters to change the order.
Compatibility
Product | Supported |
FileMaker Pro | Yes |
FileMaker Go | Yes |
FileMaker WebDirect | Yes |
FileMaker Server | No |
FileMaker Cloud | No |
FileMaker Data API | No |
Custom Web Publishing | No |
Originated in version
19.0
Description
This script step performs a function in JavaScript code that is loaded by a webpage in a web viewer then waits for the JavaScript function to finish. Any value returned by the JavaScript function is ignored.
To run a FileMaker script from JavaScript, see Scripting with JavaScript in web viewers.
Notes
- While the JavaScript function is being performed, users can’t cancel the operation or perform any other actions.
- This script step doesn’t change which layout object has the focus. To change the focus to the web viewer, use the Go to Object script step.
- If the web viewer hasn’t finished loading the webpage when this script step is performed, the JavaScript function is not performed and Get(LastError) function returns an error. A web viewer might not have loaded the webpage because the web viewer has not been made visible yet, perhaps because it’s in a closed popover, not in the frontmost panel in a panel control, or not in the visible area of a layout.
- In FileMaker WebDirect:
- This script step works only if the web viewer’s webpage has the same origin as the FileMaker WebDirect webpage. See Scripting with JavaScript in web viewers.
- The user can’t click a web viewer to give it the focus. Therefore, you must specify the Object Name option or use the Go to Object script step first; otherwise, this script step will return an error.
Example 1
Performs the JavaScript function showForm without parameters in the web viewer named Calendar.
Perform JavaScript in Web Viewer [ Object Name: "Calendar" ; Function Name: "showForm" ]
Example 2
Each segment of a button bar is set up to run the following script and pass in a different FileMaker script parameter value to specify a command for a JavaScript function to perform. The script calls the processCommand function in the web viewer named WebViewer and passes in the FileMaker script parameter and current date as parameters to the JavaScript function.
Perform JavaScript in Web Viewer [ Object Name: "WebViewer" ;
Function Name: "processCommand" ;
Parameters: Get ( ScriptParameter ), Get ( CurrentDate ) ]