Wednesday, April 25, 2007

Use Javascript to detect Vista?

I encountered a strange bug today, where the same piece of javascript code works perfectly on ie 7 (7.0.6000.16386) on xp, but fails randomly on the same version of ie7 on vista. I know how to use object detection technique to figure out which version of browser it is and what kind of functionality it supports, but how am I gonna use that to tell the two supposedly the same browser from 2 different OS?

Object detection is not an option now, and the best I can find online is to check User Agent, which is not very reliable.

You can try the following code on your browser address bar:


Notices the IE versions:

2K is version 5
XP is version 5.1
vista is version 6
[1] Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20060508 Firefox/
[2] Opera/9.00 (Windows NT 6.0; U; en)
[3] Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)


No comments: