Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac: reloading document in Chrome or Firefox?

How can I tell Chrome or Firefox to reload the document in the top window? Here's what I'm using for Safari:

osascript -e '
    tell application "Safari"
      activate
      do JavaScript "history.go(0)" in document 1
    end tell
'
like image 516
Mark Harrison Avatar asked Jan 19 '10 05:01

Mark Harrison


2 Answers

Here's the code for Chrome:

tell application "Google Chrome"
    tell the active tab of its first window
        reload
    end tell
end tell

Or more concisely:

tell application "Google Chrome" to tell the active tab of its first window
    reload
end tell
like image 186
Benjie Avatar answered Sep 29 '22 19:09

Benjie


I do not think Firefox or Chrome have special Applescript support, but you can send the keystrokes (Cmd-R) to refresh the page:

tell application "Firefox"
    activate
    tell application "System Events" to keystroke "r" using command down
end tell
like image 36
Thilo Avatar answered Sep 29 '22 20:09

Thilo