Forum Moderators: open

Message Too Old, No Replies

Javascript - Windows Vista

check if user is using Windows Vista

         

gsinswai

12:20 am on Dec 6, 2006 (gmt 0)

10+ Year Member



I need a javascript to check if the user is using Windows Vista.
Can you guys please help?

Here's the detail -

If windows vista then
write

else
write

Thanks in advance

kaled

12:53 am on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will need to check the userAgent property (of the navigator object, I think).

2K is version 5
XP is version 5.1
Vista is version 6

Kaled.

penders

12:58 am on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi gsinswai, welcome to WebmasterWorld... I guess you could try searching the user agent for "Windows NT 6.0" ...?

if (navigator.userAgent.indexOf("Windows NT 6.0") > -1) { 
// Windows Vista
}

[edit]errm... like Kaled suggests ;)[/edit]

gsinswai

1:13 am on Dec 6, 2006 (gmt 0)

10+ Year Member



So this will detect if the user is on Window Vista?

penders

4:25 pm on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's the idea. Take the following user agents for example...

[1] Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
[2] Opera/9.00 (Windows NT 6.0; U; en)
[3] Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)

For FF1.5, Opera9 and IE7b respectively. The presence of "Windows NT 6.0" in each case should indicate Windows Vista.

But beware that user agents can be faked, so it's not 100%, but I don't think there is anything better?!