Refreshing all Safari Tabs

I was just trying to throw together a quick AppleScript to refresh all of the open tabs in a Safari window.

Here's my code, could someone direct me to a solution to what I thought would be an easy solution.

tell application "Safari"
    repeat with currentTab in tabs of front window
        tell currentTab to do JavaScript "location.reload()"
    end repeat
end tell

Try this:

tell application "Safari"
	repeat with eachTab in tabs of front window
		set URL of eachTab to URL of eachTab
	end repeat
end tell

I'm getting the same problem as with my code, it just doesn't seem to register the command with each tab.

The above is the equivalent of activating the address bar and hitting Return in each tab. If you open up a new window, open sites in two new tabs, scroll to the bottom of every page and then run the script you should see the loading bar in the active tab and then when you switch to the other tabs they should be back at the top of their page again (tested in Ventura/Safari 16.1).

If you're seeing something else -- what? If you're seeing that but expecting something else -- what?

This works for me on Mojave.

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2011/08/09 20:33
# dMod: 2015/11/14 16:46
# Appl: Safari
# Task: Reload Every Tab in front window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Safari, @Reload, @Tabs, @Front, @Window
--------------------------------------------------------

tell application "Safari"
   
   set tabList to tabs of front window
   
   repeat with theTab in tabList
      tell theTab to do JavaScript "location.reload(true)"
   end repeat
   
end tell

--------------------------------------------------------
2 Likes