在safari中的applescript关闭选项卡

时间:2012-09-26 12:54:28

标签: safari applescript

tell application "Safari"
        set winlist to every window
        repeat with win in winlist
                set tablist to every tab in win
                repeat with t in tablist
                        name of t as string
                end repeat
        end repeat
end tell

我可以获得safari标签的名称

如何关闭具有特定名称的标签?

3 个答案:

答案 0 :(得分:3)

这是另一种方法:

tell application "Safari"
    set winlist to count of every window
    repeat with i from 1 to winlist
        close (every tab of window i whose name = "Google")
    end repeat
end tell

答案 1 :(得分:2)

tell application "Safari"
    repeat with t in tabs of windows
        tell t
            if name starts with "autom" then close
        end tell
    end repeat
end tell

tell application "Safari" to close documents where name starts with "autom"会关闭所有包含以autom开头的标签页的窗口。

答案 2 :(得分:1)

它对我不起作用2 它们都不起作用 奇怪的是,当野生动物园没有全屏时,它确实有效 我想这是safari中的一个错误