I want to publish a patch CD. The CD will contain my files and an HTML page
which will autorun, and tell the user which patch to install. (The Microsoft
MSI installer v2 is comes in two different versions for 98/me and nt4/2000,
and need to install that before my patches get installed. I need to give the
users the correct MSI, so I need to know what their OS is. Most of our users
are not computer people, and have trouble clicking the mouse at the right
time, so they are not likely to be able to determine their OS. I used the
code below to determine if the user is on XP, and it seems to work. The
first line prints "4.0 (compatible; MSIE 6.0; Windows NT 5.1), and I just
test to look for the OS string. One would think there is a better way but I
have zero skill with Javascript.
(this works by itself, but not with other tests for NT 5.0, etc)
if (navigator.userAgent.indexOf('Windows NT 5.1') >= 0){
document.write("<br>")
document.write("<br>")
document.write("<br>")
document.write ("Windows XP detected");
}
else {
document.write ("XP Pro not detected");
}
I have to rely on javascript because this html page is being loaded from a
CD, not a website. I know how to interpret the numbers (5.0, 5.1, etc) to
find out what the OS is, but when I had "if" statements for each OS version,
they ALL printed "xxxxxxxx detected", so I guess a series of "if" statements
will not work. How could I do a switch or case statement to look at
"navigator.userAgent" output and write the link out for the appropriate MSI?
Is there some way I can parse only the OS version from the string, so I just
get the "Windows NT 5.1" or whatever part of the string? In other words,
everything after the last semicolon (I'll just live with the closing
bracket).
Thanks to everyone,
-Jeff Maestas