Specifically, Safari uses
Here’s an example of each:
A couple notes:
- Safari requires that a document is specified
I needed and end if after set pageLoaded to true to get it to work.
Thanks, you’re right. The
ifstatement needs to be on one line or include an
end if. I updated the code example.
Thanks Kevin, but you’re doing it wrong. You can, and should, specify the tab to use in both browsers! And the way to get the “active tab of active window” differs between browsers. I’ll contribute both methods here for your readers.
In AppleScript there is a handy feature called “Open Dictionary” and this is what Chrome says:
execute specifier : The tab to execute the command in.
So the format is as follows :
tell application “Google Chrome”
That will tell the current tab in the frontmost window to run the code.
The equivalent for Safari is:
tell application “Safari”
Where “front document” means the active tab in the frontmost window.
There you have it! A way to ensure your code runs in the correct tab!
John, thanks for the tip! I’ll try updating my local scripts.