• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Closing Safari Tab...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Closing Safari Tab...


  • Subject: Re: Closing Safari Tab...
  • From: Nigel Garvey <email@hidden>
  • Date: Sun, 11 Dec 2011 15:03:58 +0000

David Crowe wrote on Sat, 10 Dec 2011 11:42:13 -1000:

>I am having difficulty closing tabs in a Safari window with multiple
tabs.
>
>Take this for example:
>
>tell application "Safari" to tell window 1
>	close tab 1
>end tell
>
>Can't get much simpler than that, but while it sometimes works I
>usually get: "Safari got an error: NSInternalScriptError".
>
>The last time I ran it it worked the first time and then consistently
>failed.
>
>What I'd really like to do is close all tabs other than the current
>one. While I can do that through ctrl-clicking on the tab, automating
>it is another matter.

This works with Safari 5.1.2 in Snow Leopard:

  tell application "Safari" to close (tabs of front window whose visible is false)

Or there's this, which also works with Safari 4.1.3 in Tiger (with or
without GUI Scripting enabled):

  tell application "System Events"
    set frontmost of application process "Safari" to true
    keystroke "w" using {option down, command down}
  end tell


NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Is dock visible
  • Next by Date: Re: Is dock visible
  • Previous by thread: Re: Closing Safari Tab...
  • Next by thread: Is dock visable [sic] [visible]
  • Index(es):
    • Date
    • Thread