![]() |
Detect SP2 for XP ?
Hi,
Is there is a way to detect Service Pack 2 for XP in JS ? Can I know it from navigator.userAgent ? Thanks, Yaron |
Re: Detect SP2 for XP ?
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('S P2') != -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/ |
Re: Detect SP2 for XP ?
Thanks Martin !!!
Martin Honnen <mahotrash@yahoo.de> wrote in message news:<4157f559$0$26684$9b4e6d93@newsread2.arcor-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('S P2') != -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 > } |
Re: Detect SP2 for XP ?
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. |
Re: Detect SP2 for XP ?
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 |
Re: Detect SP2 for XP ?
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 |
Re: Detect SP2 for XP ?
On Mon, 11 Oct 2004 01:38:05 +0200, Thomas 'PointedEars' Lahn
<PointedEars@web.de> 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...) |
Re: Detect SP2 for XP ?
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. |
Re: Detect SP2 for XP ?
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) |
Re: Detect SP2 for XP ?
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... |
| All times are GMT. The time now is 07:46 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.