Detect SP2 for XP ?

Discussion in 'Javascript' started by Yaron C., Sep 27, 2004.

  1. Yaron C.

    Yaron C. Guest

    Hi,

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

    Can I know it from navigator.userAgent ?

    Thanks,

    Yaron
    Yaron C., Sep 27, 2004
    #1
    1. Advertising

  2. Yaron C. wrote:

    > 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
    }

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 27, 2004
    #2
    1. Advertising

  3. Yaron C.

    Yaron C. Guest

    Thanks Martin !!!

    Martin Honnen <> wrote in message news:<4157f559$0$26684$-online.net>...
    > Yaron C. wrote:
    >
    > > 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
    > }
    Yaron C., Sep 28, 2004
    #3
  4. Yaron C.

    cwdjr Guest

    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.
    cwdjr, Sep 28, 2004
    #4
  5. Yaron C.

    Randy Webb Guest

    cwdjr wrote:

    > 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.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Randy Webb, Sep 29, 2004
    #5
  6. Martin Honnen wrote:

    > 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
    Thomas 'PointedEars' Lahn, Oct 11, 2004
    #6
  7. Yaron C.

    Jim Ley Guest

    On Mon, 11 Oct 2004 01:38:05 +0200, Thomas 'PointedEars' Lahn
    <> wrote:

    >Martin Honnen wrote:
    >
    >> 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'.


    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...)
    Jim Ley, Oct 11, 2004
    #7
  8. Thomas 'PointedEars' Lahn wrote:
    > Martin Honnen wrote:
    >> 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'.


    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.
    Richard Cornford, Oct 11, 2004
    #8
  9. Jim Ley wrote:

    > [...] Thomas 'PointedEars' Lahn [...] wrote:
    >> Martin Honnen wrote:
    >>> 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'.

    >
    > 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
    --
    "I'd rather be an adjective than a gerund."
    -- Tom Stoppard (loosely quoted)
    Thomas 'PointedEars' Lahn, Oct 12, 2004
    #9
  10. Richard Cornford wrote:

    > 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
    --
    Hmmm, well we can fix it, but it's going to cost you...
    Thomas 'PointedEars' Lahn, Oct 12, 2004
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Novice
    Replies:
    5
    Views:
    495
  2. coollzh

    NLB with Application center 2000 sp2

    coollzh, Jun 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    388
    coollzh
    Jun 2, 2004
  3. Kevin Spencer
    Replies:
    3
    Views:
    338
    John Saunders
    Jun 25, 2004
  4. George
    Replies:
    5
    Views:
    761
    =?Utf-8?B?S2VuIEJlYXJk?=
    Aug 24, 2004
  5. Likhith Areekkal

    Calendars overlap : IE SP2 ; WinXP SP2

    Likhith Areekkal, Dec 23, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    126
    Likhith Areekkal
    Dec 23, 2004
Loading...

Share This Page