Welcome to WebmasterWorld Guest from 3.93.74.227

Forum Moderators: open

Message Too Old, No Replies

Javascript - Windows Vista

check if user is using Windows Vista

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

New User

10+ Year Member

joined:Dec 6, 2006
posts:4
votes: 0


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

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

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


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.

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

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts:3153
votes: 7


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]

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

New User

10+ Year Member

joined:Dec 6, 2006
posts:4
votes: 0


So this will detect if the user is on Window Vista?
4:25 pm on Dec 6, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3153
votes: 7


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?!