0

我到处搜索,包括这里,寻找关闭标签的方法。我有这个应该工作的代码:

tell application "Safari"
    repeat with aWindow in windows
        repeat with aTab in tabs of aWindow
            if name of aTab is "Facebook" then
                tell aTab to close
            end if
        end repeat
    end repeat
end tell

我打开了一个 Facebook 选项卡,但它不工作,但关闭整个窗口时代码似乎工作......</p>

谢谢!

4

1 回答 1

1

尝试:

tell application "Safari" to close (every tab of every window whose name = "Facebook")

您需要在代码的重复循环中包含内容。

tell application "Safari"
    repeat with aWindow in windows
        repeat with aTab in tabs of (contents of aWindow)
            set aTab to contents of aTab
            if name of aTab is "Facebook" then
                tell aTab to close
            end if
        end repeat
    end repeat
end tell
于 2013-06-04T22:10:06.050 回答