O'Reilly logo

AppleScript: The Missing Manual by Adam Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Safari

For years, Microsoft was the dominant company in Mac Internet programs. Internet Explorer (IE), Microsoft's Netscape-devouring Web browser, came preinstalled on all Macs, and with good reason: for a while, IE was the fastest, least crash-prone Web browser available on the Mac.

However, as time went on, Microsoft slowed down development on Internet Explorer for Mac. Other Web browsers began to join the crowd: OmniWeb, Mozilla, Camino (formerly known as Chimera), Opera, and other similarly strange-named programs. Soon Apple decided to join the party, with its own browser named Safari. With emphasis on speed and simplicity, Safari quickly eclipsed Internet Explorer as a favorite of Mac fans worldwide. In fact, more than a million people downloaded Safari within the first two weeks of its existence.

Opening Web Sites

The simplest thing you can do with any Web browser is, of course, load a Web site. Thanks to AppleScript, however, you can load multiple Web sites, automatically and without fuss, by commanding Safari. That way, you can use AppleScript to load all your favorite Web sites as you're eating breakfast and come back to find all your pages just waiting to be read.

Here's how:

tell application "Safari"
    activate
    open location "http://www.apple.com/"
    open location "http://www.apricot.com/"
    open location "http://www.banana.com/"
end tell

The open location command lets you tell Safari what sites to load; if you have multiple open location commands, Safari will load multiple pages ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required