1

I'm trying to change the focus on safari for the next tab (and the previous tab)

I wrote this which is not working :

tell application "Safari Technology Preview"
    tell window 1
        set myTabNumber to current tab
        set current tab to (myTabNumber - 1)
    end tell
end tell

How can I handle this?

Update :

Thought this would be better but nope... :

    tell application "Safari Technology Preview"
    tell window 1

        set myTab to (index of current tab)

        set goodtab to (myTab + 1)

        set current tab to tab goodtab
    end tell
end tell

2 Answers 2

3

This is what you want:

tell application "Safari"
    tell window 1
        set currentTab to (get index of current tab)
        set current tab to tab (currentTab  - 1)
    end tell
end tell

You need to be specific, otherwise you end up with type-conversion issues.

1
  • Yes this work as well + make more sense. Thank you
    – Kevin
    Apr 14, 2019 at 17:36
0

Find it, the issue was I can't do last tab + 1 as the tab don't exist, so I add a if statement to set the tab to 1 if the tab don't exist (to loop in the tab)

tell application "Safari Technology Preview"
    tell window 1   
        set myTab to (index of current tab)
        set goodtab to (myTab + 1) as integer
        try
            set current tab to tab goodtab
        on error
            set current tab to tab 1
        end try

    end tell
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .