如何告诉Chrome或Firefox在顶部窗口重新加载文档?这是我用于Safari的内容:
osascript -e '
tell application "Safari"
activate
do JavaScript "history.go(0)" in document 1
end tell
'
答案 0 :(得分:39)
以下是Chrome的代码:
tell application "Google Chrome"
tell the active tab of its first window
reload
end tell
end tell
或者更简洁:
tell application "Google Chrome" to tell the active tab of its first window
reload
end tell
答案 1 :(得分:9)
我不认为Firefox或Chrome有特殊的Applescript支持,但您可以发送击键(Cmd-R)来刷新页面:
tell application "Firefox"
activate
tell application "System Events" to keystroke "r" using command down
end tell
答案 2 :(得分:5)
这是在不使用JavaScript的情况下在Safari中执行此操作的另一种方法:
tell application "Safari"
tell its first document
set its URL to (get its URL)
end tell
end tell
答案 3 :(得分:1)
tell application "Google Chrome" to tell the active tab of its first window
reload
end tell