Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Open current Safari tab in a new window via AppleScript Web Browsers
Sometimes when I have many pages loaded as tabs in one Safari window, I would like to look at two of those pages at once. So I wrote an AppleScript called Load Tab in New Window (view source, download compiled script) that re-opens the frontmost tab in a new window and closes the original tab, effectively popping the page out into its own window. It's not perfect, but I find it handy.

If you need a bit more detail on the script, you can read about it here. This is somewhat similar to this hint, but much simpler.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[13,882 views]  

Open current Safari tab in a new window via AppleScript | 14 comments | Create New Account
Click here to return to the 'Open current Safari tab in a new window via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open current Safari tab in a new window via AppleScript
Authored by: dmmorse on Dec 20, '06 09:30:53AM

I know that scripting is all the rage, but why not do this the old-fashioned way?

cmd-L to select the URL field
cmd-optn-return to open URL in new window behind current window
cmd-w to close tab

To me, these keystrokes can be performed much more quickly than a script. What's more, the keystrokes can easily be automated with any one of a number of programs.



[ Reply to This | # ]
keystroke efficiency
Authored by: anoved on Dec 20, '06 10:07:38AM

Well, a script can be invoked with a single keystroke, also using one of the many tools you mention. For instance, I don't actually go to the scripts menu to run this; I use FastScripts to run it with Command-\.

There is usually more than one way to do something: in addition to the sequence you point out, you could press Command-L, Command-C, Command-W, Command-N, Command-V. It's longer, but even more obvious.

As with many hints, I'm simply offering an alternate way to do something that is already quite possible.



[ Reply to This | # ]
keystroke efficiency
Authored by: fooljay on Dec 20, '06 12:17:35PM

Command-L, Command-shift-option-return opens the current tab in a new window. Two Command-W's and both are closed...



[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: AquaX on Dec 20, '06 10:52:39AM

Could a similar script be written that does the complete opposite? It would take all open Safari windows and tabs and re-open them as tabs within a single window. Useful for those sites that demand to open things in new windows instead of tabs, and without having to run some sort of hack or Safari enhancement.



[ Reply to This | # ]
combining windows and tabs
Authored by: anoved on Dec 20, '06 11:00:19AM
I think so. Apple provides an example script called Combine Windows here that almost does it, except it only takes the frontmost tab from each open window. To retain all the tabs of each window you'd probably have to resort to more UI scripting, but I think it could be done. I agree that would be a worthwhile script.

[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: faunzy on Jan 09, '09 10:40:14AM
Combining all open windows in Safari is easy. Its in Window > Merge All Windows

[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: lambertd on Dec 21, '06 08:53:11AM
If you set Preferences… > General > New window opens with: to Same Page, all you have to do is hit Cmd-N.

[ Reply to This | # ]
closing previous tab
Authored by: anoved on Dec 21, '06 09:55:39AM

That's a good point and a pretty good tip. I forget about that option. Ideally it would be possible to close the previous tab by holding down option or something when pressing Command-N, as the main effect I was shooting for here was to "pop" a page out of its tab into a window, without leaving the original copy behind. Still, this is good. Thanks.



[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: delarius on Dec 31, '06 05:21:08PM

I do like the old fashioned way, for sure, but neither addresses what I think should be the main goal in this: popping a tab to a window w/o interrupting the 'session.' For example, if while writing this comment, I use either your script or press command-l, command-option-return; it interrupts the session. As far as I can see, the only way of doing it is to just close all the tabs - or repop them on another window (as tabs) by whatever means. There must be a way of popping a tab into a window while retaining the logins, etc, etc. Ok, I'll admit, I'm playing a flash game and I realize it's so slow (and doesn't do anything unless it's the top tab - tab, not window) that I need it to be it's own window.
I shall investigate,
Del



[ Reply to This | # ]
I concur but don't know how to do it
Authored by: anoved on Jan 01, '07 03:30:17PM
...should be the main goal in this: popping a tab to a window w/o interrupting the 'session.' For example, if while writing this comment, I use either your script or press command-l, command-option-return; it interrupts the session...

Absolutely. As I noted in the script, 'ideally the page would just be "moved" to a new window without reloading it,' which I think is getting after the same thing. There are many cases where it'd be nice to move something like an email or comment in progress or a video that's being played to a new window, but obviously my script isn't much help in such cases as the page is actually just closed and reloaded. If I knew a better way to handle page content in AppleScript I'd definitely use it.



[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: palahala on Jan 10, '09 04:08:21AM
For a moment I thought this was about CLONING the existing tab to a new window, to get two instances. But as you're closing the original tab: why not do it the Safari way? ;-)

Simply drag the tab away from the tab bar let go. This will disconnect the tab as a standalone window, and will give you a nice effect as well.

Or: menu Window, Move Tab to New Window?

(If you'd like a split screen within the very same tab, then these bookmarklets might help you: http://pimpmysafari.com/bookmarklets/ but I doubt that is what you want)


[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: palahala on Jan 10, '09 04:15:15AM

Oh, I now see this was quite an old hint. Anyway, the latest Safaris support this feature; don't know about the 2006 versions :-)



[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: Cezary Okupski on Jan 28, '09 02:33:45PM

I imagine that the solution was needed in times of Safari 2 and, palahala, you are right that now in Safari 3 you can just drag & drop.



[ Reply to This | # ]
Open current Safari tab in a new window via AppleScript
Authored by: Thom on Feb 04, '09 09:51:14AM

Now that it's built in, I wonder if anyone has written a script to take the next logical step: The ability to (with one command) take all of the tabs in the current window (at once) and split them all out to their own windows? If not, I wonder how hard it would be to code that.



[ Reply to This | # ]