Web developers have applauded the standards-based approach that Apple has taken in designing Safari, because it means supporting Safari is relatively simple and painless. Most developers are happy to follow the W3C guidelines and have their pages "just work," with no need for browser-specific HTML. However, Safari has the features you'd expect of a modern browser plus a few unique ones; understanding these, as well as a few Safari development tricks, will ensure your web property works exactly the way you and your users expect.
Detecting User Information
Safari identifies itself with the following User-agent string:
where XX is the version of Apple's web technology used by Safari and YY is the version of the Safari application. The AppleWebKit/XX portion identifies the rendering engine and can be used to pinpoint the exact version of Safari that is being used. Here is code to check your user-agent string:
Here is the function displayed in action:
Various aspects of the browser can be retrieved as values of the
Here it is in action:
Show your browser's value for navigator.
This function detects explicitly whether the user is using a browser based on the Web Kit:
And here it is displayed in action:
To detect a Safari user's preferred language, use the
Here is an example of using object detection to test if a browser has support for DHTML:
This checks for the various DOM objects used by various browsers to
provide DHTML support—
Cookies, Caching, and Address Bar Icons
Safari (and other browsers) speed up user-end response times by caching static and semi-static content, including cookies. This behavior can be prevented by passing the following HTTP headers to the browser:
This can be done with PHP as follows:
This button checks your browser for cookies:
Safari is compatible with the favorites-icon standard, which displays a 16-by-16-pixel icon in the address bar, like this one:
The icon is supplied by the website. In order to provide a favorites icon to compatible browsers, place the following code in the HEAD area of HTML documents:
See the article on Hotwired's Webmonkey site: All About the Favorites Icon to learn how to create and display favorites icons.
Since the release of Java 1.4.1
for Mac OS X, Safari can work with either Java 1.4.1 or 1.3.1. The
Java 1.4.1 plugin,
All plugins for Safari reside in the
Safari offers as complete as possible an implementation of the Cascading Style Sheets standard. There are some lacunae and caveats, detailed in the Internet Developer article, CSS Support in Safari.
Miscellaneous Safari Tips
Safari incorporates a built-in pop-up window blocker, which disables
pop-up windows triggered by <script> tags, the
Safari's time-out behavior is as follows: the browser will time out if it does not receive a response to an HTTP request or if server data transmission stops for 60 seconds.
Safari follows the HTML specification in rendering Web pages. Pages can be tested for standards compliance, and hence Safari compliance, using the W3C's HTML Validator.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
Copyright © 2003 Apple Computer, Inc.