Information about your Web browser

Using JavaScript to identify your Safari Web browser

Some Web sites are designed to work correctly only with certain browsers, and some sites will not even let you access them unless you are using one of their approved browsers. All browsers provide information about their identity that can be queried by Web sites and computer programs, but it is not normally visible.

This Web page checks that you are using a Safari browser, makes the information about its identity visible, attempts to determine whether it is spoofing, and attempts to display its version number.

Identify other Web browsers

Which Safari Web browser am I using?

If your browser could not be identified, or if it was identified incorrectly, then please send me a message so that I can try to improve the identification.


Some Web browsers can be configured to supply identification that belongs to other browsers, a process known as spoofing. This can allow browsers to access Web sites that attempt to restrict access to specified browsers. Perfect spoofing would be impossible to detect.


Safari always identifies its vendor as Apple, and this always allows it to be detected when it pretends to be Internet Explorer or other browsers, but not when it pretends to be other versions of Safari.

To set up spoofing, the Develop menu needs to be made visible:

  1. Open the “Settings” menu by clicking the gear icon.

    Accessing Preferences in Safari

  2. Select “Preferences…”.
  3. In the Preferences dialog box, select the “Advanced” icon.

    Making the Develop menu visible in Safari

  4. Click the check box so that a tick appears next to “Show Develop menu in menu bar”
  5. Close the Preferences dialog box by clicking the red button at the top left (OS X) or by clicking the X icon at the top right (Windows).

Then choose a User Agent:

  1. If the Menu Bar is not visible, press the “Alt” key. (The first option on the Settings menu will make it stay visible.)
  2. Open the “Develop” menu.
  3. Point to “User Agent”.

    Setting Safari to spoof as Internet Explorer 7.0

  4. In the sub-menu that appears, select the browser that you want Safari to imitate.

How are you identifying my Safari browser?

There are several ways of identifying a browser, but this page uses some fairly simple JavaScript that someone without programming experience can understand and modify.

The first step is to make sure that you are using a Safari browser, by checking for the presence of the string “apple” in the vendor property of the JavaScript navigator object. If this is not found, then a message and a link to the main browser identification page will be displayed.

if (navigator.vendor.toLowerCase().indexOf("apple") == -1)
document.write("<p><strong>You do not appear to be using a Safari Web browser.<\/strong><\/p>");

The second step is to retrieve the userAgent data that your Safari browser supplies as part of the JavaScript navigator object, for example:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080201 Firefox/

The third step is to convert the data to lower case and search it for one or more strings of characters whose presence and/or absence (alone or in combination) can be used to detect spoofing and to identify a browser. For example, the following definition specifies the presence of “firefox/2”.

else if (navigator.userAgent.toLowerCase().indexOf("firefox/2") != -1)

This indicates that your Safari browser is configured to spoof as Firefox 2, and so when a match is found, this causes the next piece of JavaScript to write some HTML that displays a message as part of the Web page:

document.write("<p><strong>Your Web browser claims to be Firefox version 2, but appears to be Safari providing a false identity.<\/strong><\/p>");

The fourth step is to check for a string that indicates the browser version, for example:

else if (navigator.userAgent.toLowerCase().indexOf("version/3.1") != -1)

Finding a match causes the next piece of JavaScript to write some HTML that displays a message about the version as part of the Web page:

document.write("<p><strong>Your version of Safari appears to be 3.1<\/strong><\/p>");

This type of identification is not completely accurate, especially when browsers pretend to be other browsers, but it works most of the time.

Send comments or questions to Alan Wood

Valid HTML 4.01     Unicode Encoded
Created 20th December 2001   —   Updated 8th March 2024
Copyright © 2001–2024 Alan Wood

Alan Wood’s Web site