views:

209

answers:

2

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
'
+3  A: 

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
Thilo
Firefox is supposed to but it's been broken with current 3.5.x releases, apparently.
Ned Deily
Nifty! This works for all three browsers, using "Firefox", "Google Chrome", and "Safari" as application strings.
Mark Harrison
+1  A: 

Here's another way to do it in Safari without using JavaScript:

tell application "Safari"
    tell its first document
        set its URL to (get its URL)
    end tell
end tell
Ned Deily