Detect SP2 for XP ?

Y

Yaron C.

Hi,

Is there is a way to detect Service Pack 2 for XP in JS ?

Can I know it from navigator.userAgent ?

Thanks,

Yaron
 
M

Martin Honnen

Yaron said:
Is there is a way to detect Service Pack 2 for XP in JS ?

Can I know it from navigator.userAgent ?

With IE 6 it seems that
navigator.appMinorVersion
contains
SP2
if Windows XP service pack 2 is installed thus the check
if (navigator.appMinorVersion &&
navigator.appMinorVersion.toLowerCase().indexOf('SP2') != -1) {
// it is SP 2
}
should help (as long as not any other browser vendor on another platform
decides to use that property and put SP2 into it for some reasons).
I don't think other Windows browsers care about the service pack and
indicate it in some navigator property.
And even with IE you are probably better off if you simply do object
checking e.g.
var win = window.open('whatever.html');
if (win != null && !win.closed) {
// manipulate window here
}
 
Y

Yaron C.

Thanks Martin !!!

Martin Honnen said:
With IE 6 it seems that
navigator.appMinorVersion
contains
SP2
if Windows XP service pack 2 is installed thus the check
if (navigator.appMinorVersion &&
navigator.appMinorVersion.toLowerCase().indexOf('SP2') != -1) {
// it is SP 2
}
should help (as long as not any other browser vendor on another platform
decides to use that property and put SP2 into it for some reasons).
I don't think other Windows browsers care about the service pack and
indicate it in some navigator property.
And even with IE you are probably better off if you simply do object
checking e.g.
var win = window.open('whatever.html');
if (win != null && !win.closed) {
// manipulate window here
}
 
C

cwdjr

I checked this out at my browser "zoo" of 9 browsers and found 3
browsers that return ;SP2; when asked for navigator.appMinorVersion.
However the other 7 did not. Since the SP2 update apparently makes
changes both in the XP OS and IE6 browsers and relatves thereof, this
response of browsers is no surprise. IE6, MSN9, and MYIE2 0.9.27.68
return ;SP2; . Opera 7.54 just gives a blank space. Mozilla 1.7.3,
Netscape 7.2, Firefox 1.0 Preview Release, and Netscape 4.8 return
undefined. Amaya 8.16 does not have JS installed. The old MSNTV
browsers, soon to be replaced by a IE6 browser on a new set top box
just being released, return numbers for various version revisions, but
no letters. It is possible that some AOL browsers could return ;SP2;
since some of these are based on IE6, but AOL greatly modifes the
browser. I have no way to check various AOL browser versions.
 
R

Randy Webb

cwdjr said:
It is possible that some AOL browsers could return ;SP2;
since some of these are based on IE6, but AOL greatly modifes the
browser. I have no way to check various AOL browser versions.

AOL 9 runnin on WinXP SP2 returns the SP2, but as you pointed out, the
SP2 is no guarantee that you can assume its going to act as IE6 does,
there are subtle differences.
 
T

Thomas 'PointedEars' Lahn

Martin said:
var win = window.open('whatever.html');
if (win != null && !win.closed) {
// manipulate window here
}

I would rather do

var win = window.open('whatever.html');
if (win && !win.closed)
{
// manipulate window here
}

since `win' could for some reason be `undefined'.


PointedEars
 
J

Jim Ley

I would rather do

var win = window.open('whatever.html');
if (win && !win.closed)
{
// manipulate window here
}

since `win' could for some reason be `undefined'.

and if window.open returned false [*]? As it does in certain old
pop-up blockers I've seen?

Jim.

[*] (or true, or any object which didn't have a closed property...)
 
R

Richard Cornford

Thomas said:
I would rather do

var win = window.open('whatever.html');
if (win && !win.closed)
{
// manipulate window here
}

since `win' could for some reason be `undefined'.

The possibility that - win - is undefined is already covered in the
original test as in the type-converting equality operation (null ==
undefined) is true so (win != null) will be false if win is null OR
undefined. Straight type-converting to boolean might be preferred for
its relative simplicity and efficiency.

Richard.
 
T

Thomas 'PointedEars' Lahn

Jim said:
I would rather do

var win = window.open('whatever.html');
if (win && !win.closed)
{
// manipulate window here
}

since `win' could for some reason be `undefined'.

and if window.open returned false [*]?
As it does in certain old pop-up blockers I've seen?

Then the first operand would be converted to `false' as well, the
second operand would not be evaluated and everything would be fine.
[*] (or true, or any object which didn't have a closed property...)

(Why should it? B0rken popop blockers?) The condition would then evaluate
to `true'. Further tests whether `win' can be used as object reference
would be necessary. Since the window should be manipulated within the
block, this could and should be achieved with feature tests prior to
access.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Richard said:
The possibility that - win - is undefined is already covered in the
original test as in the type-converting equality operation (null ==
undefined) is true so (win != null) will be false if win is null OR
undefined. Straight type-converting to boolean might be preferred for
its relative simplicity and efficiency.

ACK, thanks. I tend to forget about that conversion.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top