2013-06-04 54 views
0

我到處搜尋,包括這裏的方式來關閉一個標籤。 我有這樣的代碼應該工作:關閉一個Safari瀏覽器選項卡

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標籤頁中打開,它不工作,代碼看起來雖然整體關閉窗口時工作...

謝謝!

回答

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 
+0

代碼錯誤我害怕,我看不出爲什麼! –

+0

這兩個腳本都產生了一個錯誤? – adayzdone

+0

你的人做到了。我的一個產生一個似乎一切正常的日誌,但該標籤保持打開狀態。嘗試運行它。 –

相關問題