By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

Determine the versions of Safari

P: n/a
How can I determine the version of Safari (for example, 1.0.2 or 1.2.2)
that's downloaded a document?

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a

displays the browser info.

For Safari 1.2.2 (v125.8)
navigation.userAgent returns

Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/125.2
(KHTML, like Gecko) Safari/125.8

So it looks like you can take that and slice it with a / to make an
array. Then array_name[3] will be the Apple build number of Safari
used. Now as far as getting the specific info you requested we'd need
to see how other versions of Safari display the userAgent to see if
the build number and the version number match up. But this is a start.
Marcia Gulesian <> wrote in message news:<41***************>...
How can I determine the version of Safari (for example, 1.0.2 or 1.2.2)
that's downloaded a document?

Jul 23 '05 #2

P: n/a
Marcia Gulesian wrote:
How can I determine the version of Safari (for example,
1.0.2 or 1.2.2) that's downloaded a document?

It is almost never a good idea to have any interest in the type or
version of a web browser. Mostly because it is impossible to extract
that information accurately; the majority of browsers spoof other
browsers to some degree or another (by default, under user configuration
or both).

Instead you solve your problem by understanding why you think you need
this information. You will probably find that the reason for wanting to
know which version a particular browser is directly follows from a
change in support for a particular feature. For example, recent Safari
versions have introduces - XMLHttpRequest - so a script that wanted to
use that feature would work on those later versions and fail on earlier
versions. To match a script's desire to use - XMLHttpRequest - with a
browser's ability to provide it (in a precise one-to-one relationship)
code such as:-

/* This code was original posted to comp.lang.javascript
by Martin Honnen:-
var httpRequest;
if (typeof ActiveXObject != 'undefined') {
httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
else if (typeof XMLHttpRequest != 'undefined') {
httpRequest = new XMLHttpRequest();
if (httpRequest) {
//open(httpRequestMethod, URL, async)'GET', 'whatever.html', true);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4) {

- can be used

Internet Explorer has its own (ActiveX) equivalent of - XMLHttpRequest -
so if that is available it is used, otherwise the test:-

if (typeof XMLHttpRequest != 'undefined') {

- distinguishes browsers with support for the feature from browsers that
lack it, but without *any* interest in the type or version of those

Beyond the fact that this (feature detection) style of coding avoids any
need to be interested in the type or version of browser at the client
end (and so side-steeps the impossibility of knowing that information
with certainty), it also offers benefits in terms of ongoing code

Any interest in the type or version of a web browser implies a need for
possible updating whenever a new version (or new type) of a browser is
released. Google's new gMail system illustrates this aspect of this
style of implementation quite well, because it is not well implemented.

gMail uses XML HTTP requests in their various forms but google's
javascript authors are notoriously poor and know no better than to be
using userAgent strings to detect (more, guess at) web browser type and
version to decide when a client browser is to be allowed to use gMail.

Currently Opera 7 does not support XML HTTP requests in any form so the
google programmers are rejecting any browser that appears to be Opera,
but rumours on the opera newsgroups (contributed to by developers at
opera) are that the next major version will implement - XMLHttpRequest -
and so will work with gMail.

When Opera 7 introduces - XMLHttpRequest - google's programmers have two
choices; needlessly exclude these new versions of Opera, or re-visit
their browser detecting code and attempt to accommodate the new version.
The first option would seem to give an arbitrary penalty to the users of
Opera (and fail to reward its developers for their efforts to facilitate
gMail) and the second option is going to cost google money in paying
someone to make the changes.

The feature detection style code does not carry this burden as soon as
it is exposed to a version of Opera that supports - XMLHttpRequest - it
will work with that version, at no extra effort or expense. And, of
course, the script also immediately supports any other browser that
supports, or introduces - XMLHttpRequest -, again with no additional
work on the part of the web site using that style of script.

<URL: >

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.