This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
actions:Execute_a_JavaScript_in_Browser [2017/08/31 02:08] peternlewis |
actions:Execute_a_JavaScript_in_Browser [2021/03/24 19:37] JMichaelTX ADD icon |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | The *Execute a JavaScript in Browser* actions let you execute a JavaScript in the active web browser page. | + | {{:actions:javascript-icon-small.png?nolink |}} ====== Execute JavaScript in Browser Actions ====== |
- | Like other [[Browser_Actions|browser actions]], these actions work with Safari or Google Chrome (or whichever of the two was last at the front). | + | There are several *Execute a JavaScript in Browser* actions let you execute a JavaScript in a web browser page: |
- | Alternatively, you can execute JavaScript in a specified [[action:Custom_HTML_Prompt|Custom HTML Prompt]] window. | + | * _Execute a JavaScript in **[[action:Custom_HTML_Prompt|Custom HTML Prompt]]**_ |
+ | * _Execute a JavaScript in **Front Browser**_ | ||
+ | * The "Front Browser" is whichever of the following is currently frontmost, or was the last web browser that was frontmost: | ||
+ | * Google Chrome | ||
+ | * Safari | ||
+ | * Chrome-based Browsers like Brave Browser | ||
+ | * _Execute a JavaScript in **Google Chrome**_ | ||
+ | * _Execute a JavaScript in **Safari**_ | ||
- | This action allows you to execute a specified JavaScript, either from a file or text entered in the Action itself, and return the results. | + | All of these Actions work the same. The difference is in which Web Browser the JavaScript will be executed. |
- | If you need to access other Mac apps, see [[action:Execute_a_JavaScript_For_Automation|Execute JavaScript for Automation (JXA) Action]]. | + | This action allows you to execute a specified JavaScript, either from a file or text entered in the Action itself, and return the results. |
- | {{:action:km-execute-javascript-chrome.png?nolink|}} | + | {{:actions:execute-javascript-browser-action.png?nolink|}} |
===== Options for Returning Results ===== | ===== Options for Returning Results ===== | ||
Line 36: | Line 43: | ||
===== Saving Results to Keyboard Maestro Variables ===== | ===== Saving Results to Keyboard Maestro Variables ===== | ||
| | ||
- | If you need to set a Keyboard Maestro Variable from the JavaScript in a browser, then use a JavaScript return to return the data to the Keyboard Maestro Action, which can be set to save the results as a Keyboard Maestro Variable. | + | If you need to set a Keyboard Maestro Variable from the JavaScript in a browser, then use the JavaScript return value to return the data to the Keyboard Maestro Action, which can be set to save the results as a Keyboard Maestro Variable. |
If you need to set more than one Keyboard Maestro Variable, one approach is to return the data for each variable on a separate line (or with delimiters of your choice), and then parse in a following [[action: Search_using_Regular_Expression|Search using Regular Expression]]. | If you need to set more than one Keyboard Maestro Variable, one approach is to return the data for each variable on a separate line (or with delimiters of your choice), and then parse in a following [[action: Search_using_Regular_Expression|Search using Regular Expression]]. |