Sometimes I want to open a web page in Google Chrome, but without switching to the browser. I have an applescript command (osascript -e 'tell application "Google Chrome" to open location "URL"'
) to open a web page, but it activates the browser. Is there a way to open a web page in the browser without activating it?
The script below opens the link with no errors but activates Google Chrome. I'm not sure why is that the case.
tell application "Google Chrome"
open location "chrome://settings" without activating
end tell
Best Answer
There may have been a time when Google Chrome was compliant with AppleScript commands e.g.
run
orlaunch
, which would keep it in the background, as it does with e.g. Safari and other applications. Or compliant with with the shellopen
command using either the-g
or-j
options along with the-a
option.In testing under macOS Catalina I could not get Google Chrome to consistently open in the background and only with the
open
command with-jga
would it open in the background a few different times, but not at all consistently.Google clearly is not conforming to the macOS norms!
That said, the only way I could consistently open a URL in Google Chrome in the background was is if it was already running with an open window in the background.
I'll post the example AppleScript code just for you to test if it works for you as it did for me.