This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
action:Execute_a_JavaScript_For_Automation [2023/04/03 00:01] peternlewis |
action:Execute_a_JavaScript_For_Automation [2023/09/12 22:49] peternlewis [Script Results] |
||
---|---|---|---|
Line 17: | Line 17: | ||
By default, errors are not included in the output, and the output is trimmed of white space. These can be adjusted in the action (gear) ⚙ menu. | By default, errors are not included in the output, and the output is trimmed of white space. These can be adjusted in the action (gear) ⚙ menu. | ||
+ | |||
+ | ===== Modern Syntax ===== | ||
+ | |||
+ | In version 11.0, scripts default to Modern Syntax, which essentially wraps the script in: | ||
+ | |||
+ | ```javascript | ||
+ | (function () { | ||
+ | … | ||
+ | })() | ||
+ | ``` | ||
+ | |||
+ | This helps keep your script from interacting with the web page in unexpected ways. A result of this is that you need to return values to the action using the `return` syntax. So a trivial action would be: | ||
+ | |||
+ | ```javascript | ||
+ | return "Hello"; | ||
+ | ``` | ||
+ | |||
+ | You can turn Modern Syntax on or off in the popup menu next to the script. | ||
===== Get/Set Keyboard Maestro Variables ===== | ===== Get/Set Keyboard Maestro Variables ===== |