Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / November 2005



Tip: Looking for answers? Try searching our database.

Detect and Display Windows Version

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich@nospam.com - 28 Nov 2005 18:23 GMT
Please help.  Looking for a script to detect and display what version of
Windows a user is running.

Thanks in advance.
Rich
Randy Webb - 28 Nov 2005 22:51 GMT
Rich@nospam.com said the following on 11/28/2005 1:23 PM:
> Please help.  Looking for a script to detect and display what version of
> Windows a user is running.

When you find it, can you post back the results it gives when executed
on a MAC or a Linux based system?

But, stop looking as trying to figure out what you are trying to figure
out goes outside the security boundaries of the browser.

But, if your users need you to tell them the OS, they don't need a
computer.....

Signature

Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Rich@nospam.com - 28 Nov 2005 23:10 GMT
The scipt is for an intranet site.  We only have Win OS machines so MAC and
Linux is not an issue.  What I am trying to do is show the user their OS,
version of Media Player and Browser version.  I am able to do the last 2 but
can't figure out how to show the OS.
VK - 28 Nov 2005 23:23 GMT
> The scipt is for an intranet site.  We only have Win OS machines so MAC and
> Linux is not an issue.  What I am trying to do is show the user their OS,
> version of Media Player and Browser version.  I am able to do the last 2 but
> can't figure out how to show the OS.

You cannot do it directly from the available browser info, because in
userAgent string (and other places) Microsoft uses version codes (5.0,
5.1 etc) and not the market names like Windows ME, Windows XP etc.

So you have to make (or find) a match table {version code : marken
name}, study navigator.userAgent for code and display the match from
that table.

This is the only way I can think of.
VK - 30 Nov 2005 18:46 GMT
> You cannot do it directly from the available browser info, because in
> userAgent string (and other places) Microsoft uses version codes (5.0,
[quoted text clipped - 3 lines]
> name}, study navigator.userAgent for code and display the match from
> that table.

And these Microsoft tables will help you:
<http://msdn.microsoft.com/workshop/author/dhtml/overview/aboutuseragent.asp#UARe
gistry
>
RobG - 28 Nov 2005 23:49 GMT
> Please help.  Looking for a script to detect and display what version of
> Windows a user is running.
>
> Thanks in advance.
> Rich

There's a place called the Microsoft Developer Network (MSDN) that you
can search for such things.

You can look at the platform property of the navigator object, or you
can try the clientInformation object (they seem identical for all
practical purposes).  All you will get for the platform is 'Win32' which
is probably anything from Windows 95 onward (or maybe even Windows 3.1
with the 32-bit stuff added, I dunno) and note that users can likely
spoof that if they want.

The properties of both objects are shown in IE by the following ( -
Mozilla/Gecko does not support the clientInformation object):

<script type="text/javascript">

var HTMLstring = '';
if ('object' == typeof navigator){
  HTMLstring += '<h1>Navigator properties</h1>';
  for (var prop in navigator){
    HTMLstring += '<b>' + prop + '</b>: ' + navigator[prop] + '<br>';
  }
}
if ('object' == typeof clientInformation){
  HTMLstring += '<h1>clientInformation properties</h1>';
  for (prop in clientInformation){
    HTMLstring += '<b>' + prop + '</b>: ' + clientInformation[prop] +
'<br>';
  }
}
document.write(HTMLstring);

</script>

Navigator object:
<URL:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_navigator.asp

clientInformation object:
<URL:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_clientinfo
rmation.asp


Signature

Rob

Rich@nospam.com - 29 Nov 2005 00:16 GMT
A while ago I found a script that was able to redirect a user based on the
version OS.  At the time I only needed to detect NT4 vs Win2k/XP.  Here is
the script:

<script>
var n = navigator;
var ua = ' ' + n.userAgent.toLowerCase();

// find windows platform

var is_win = ua.indexOf('win') > 0;
var is_winnt4 = (ua.indexOf('nt 4.0') > 0 && ua.indexOf('win') > 0);

if(is_winnt4){document.location = "wm_player_framesetnt.html"}
else {document.location = "wm_player_framesetxp.html"}
</script>

This is why I thought it was possible to also detect Win2k vs XP.
RobG - 29 Nov 2005 03:08 GMT
> A while ago I found a script that was able to redirect a user based on the
> version OS.  At the time I only needed to detect NT4 vs Win2k/XP.  Here is
[quoted text clipped - 14 lines]
>
> This is why I thought it was possible to also detect Win2k vs XP.

The user agent string for IE on the machine that I'm using at the moment
comes up as:

  Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

You work it out[1].  :-)

I think as VK says, you need to reverse engineer it.  Every time you get
a user agent string you can't decipher or haven't come across before,
visit the machine, find out what it's running and add it to your
user-agent-deciphering routine.

But it will only work if you can control what the UA string is (the sys
admins at some places I work do, but not all).  How do you know someone
isn't running some other browser/UA and putting whatever in the UA string?

1. XP Pro SP 1

Signature

Rob

Randy Webb - 29 Nov 2005 11:40 GMT
RobG said the following on 11/28/2005 10:08 PM:

>> A while ago I found a script that was able to redirect a user based on
>> the
[quoted text clipped - 34 lines]
>
> 1. XP Pro SP 1

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)

Windows XP Home SP2

It will be interesting to see how people differentiate XP Pro from XP
Home from the UA string :)

I still say you can't reliably get the OS from the browser. Keyword
being reliably.

Signature

Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

RobG - 29 Nov 2005 12:52 GMT
> RobG said the following on 11/28/2005 10:08 PM:
[...]

> Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
> 1.1.4322; .NET CLR 2.0.50727)
>
> Windows XP Home SP2

How about:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Windows 2000 Pro SP 4 (no .NET framework - I have no use for it - hence
on CLR stuff I guess).

> It will be interesting to see how people differentiate XP Pro from XP
> Home from the UA string :)
>
> I still say you can't reliably get the OS from the browser. Keyword
> being reliably.

No argument with that.

Signature

Rob

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.