Add Studio Log to My Yahoo

Tabbed browsing in Safari - What for?

By: Jesse Shanks

Combining Safari, AppleScript and the nature of the OS X system, a new and more efficient way of browsing can be created that makes the question of tabbed browsing somewhat irrelevant.

In reading the various reviews, appreciations and criticisms of Apple's new Safari browser, one thing keeps arising again and again: the desire for the Holy Grail of tabbed browsing. Many users might not have come across this phenomena if they have not taken the time to download one of the gargantuas called Mozilla or Netscape, or have not tried out the Chimera browser that was getting all the publicity prior to Safari's release.

I use my browser as an information gathering tool and I just need it to be scriptable with AppleScript. I have scripts that gather data from pages as I aggregate news and information for DVD reviews and news links on our digitallyOBSESSED.com site. Using a script I can gather the title and URL of a page, format it into a POST string and send it to a PHP script and on into the MySQL database. I have a couple of AppleScript Studio apps that post to web logs and process other information that originates in a browser.

For my purposes, I tried but quickly abandoned the "tabbing" browsers because their scripting support was spotty or missing. Microsoft's Internet Explorer has remained my main browser even though I don't like it for many reasons, one of the main ones being its tendency to just simply stall. It has a reasonable AppleScript dictionary with "do Javascript" working very nicely. But, this has changed with the advent of Safari which has the beginnings of a document-oriented scripting dictionary and GUI scripting which allows for some different techniques of grabbing data.

Like many veteran scripters, I am dubious of GUI scripting because it is a substitute for top notch scripting support and it depends on the location of things in hard-to-figure-out menu and button hierarchies. Isn't it bad enough that AppleScript continues to be so poorly documented? But, I have had some good results with using GUI Scripting in various scripts to add some things that just couldn't be reached before.

Now, I have used Netscape and Chimera and have used tabbed browsing and quickly saw the advantages of it. But, in agreement with many of the criticisms of tabbed browsing, I certainly didn't find it to be the best way of browsing nor the worst, just another way. There is a length discussion of Safari, Chimera and tabbed browsing at the Apple section of Slashdot and Dave Hyatt posts some interesting notes about the browser at his Surfin' Safari web log. Lately, amid the many cries for tabbed browsing to be added to Safari, have been various attemtps to add tabbed browsing or some semblance of it to the program. TabbedSafari 1.0 - VersionTracker is one attempt and another RealBasic effort is found at MacBase: How to Emulate Tabbed Browsing in Safari.

I ask, "What for?" A perfectly serviceable "semblance" of tabbed browsing already exists. The good ole yellow button will send a window into the dock as a tab. But clicking and holding on a link, a new window can be opened containing the URL. It would be nice if one of the options in the context menu was "Open Link in a Minimized Window." Depending on the number of applications open, dock size and/or magnification, the pages sit in their minimized windows nicely in the dock and are ready for quick acess or switching. I often end up with about six windows open on the various places I surf and the thread they lead to in my usual browsing.

In the Safari Scriptpack that I put out for download, I included a script called Six Pack of Sites that I launch in the morning when I get started.

This script really serves two purposes that I was experimenting with in making browsing more efficient. The first thing in the script is a property that defines window bounds for 6 windows.

property theWs : {{0, 22, 392, 244}, {395, 22, 782, 244}, {1, 246, 393, 468}, {396, 246, 788, 468}, {0, 470, 392, 693}, {396, 471, 788, 694}}

These windows would tile across the screen if the bounds are set in the repeat loop. Like the graphic below illustrates.



The second property is the list of URLs for the six the windows.

property URLs : {"http://my.yahoo.com", "http://www.google.com", "http://www.digitallyobsessed.com", "http://www.macsurfer.com", "http://www.blankreb.com/studiolog.php", "http://www.amazon.com/exec/obidos/redirect-home/digitallyobsesse"}

Following is the two versions of the script. The first uses the windows sizes to create the tiled-browser set up. These windows can be enlarged and then returned to this size and position. These windows have the advantage of being able to accept a drop. They can also be cycled from the keyboard with Command-tilde.

tell application "Safari"
close every window
repeat with i from 1 to count of URLs
make new document at beginning of documents
-- comment out the line below to create the windows with bounds in theWs property
set bounds of window 1 to item i of theWs
set URL of document 1 to item i of URLs
-- comment the line below to prevent miniaturization of the windows
--set miniaturized of window 1 to true
end repeat
end tell

One interesting fact is that these windows will act similarly to Finder windows when dragged to the bottom of the screen. When the green button is clicked, they enlarge to the size of the data in the web page and when it is clicked again they move back down to where they were. Almost like the tabbed windows of System 9, except that, unlike Finder windows, they will not "popup" when something is dragged over them.



The second sends the newly created windows into the dock. Nice for background downloading.

tell application "Safari"
close every window
repeat with i from 1 to count of URLs
make new document at beginning of documents
-- comment out the line below to create the windows with bounds in theWs property
--set bounds of window 1 to item i of theWs
set URL of document 1 to item i of URLs
-- comment the line below to prevent miniaturization of the windows
set miniaturized of window 1 to true
end repeat
end tell

So, various combinations of window sizes and positions could be scripted to create an opening configuration that lends itself to efficient browsing. To many surfing the web is more than just an amusement, part of the job is going to web sites and gathering information and links found there. Hopefully, the scripting support will expand in Safari to help make it more capable of processing data and the feature bloat will stay low so that it remains a crisp running application.

Bonus bookmarklet for Safari and IE:

javascript:self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);

January 31, 2003

Back

Applescript Language Guide
Applescript Language Guide; English Dialect