...

View Full Version : Find User's Operating System



techgearfree
01-30-2005, 08:36 PM
Is there any way to use javascript to find a user's operating system, and save it as a variable for use in php?

Thanks

hemebond
01-30-2005, 09:10 PM
This information is usually supplied in the HTTP headers, and can be retrieved directly with PHP.

techgearfree
01-30-2005, 09:13 PM
I tried looking for a php script to find this, but I didn't see any?

Willy Duitt
01-30-2005, 10:03 PM
I tried looking for a php script to find this, but I didn't see any?


HTTP_USER_AGENT

techgearfree
01-31-2005, 12:21 AM
Isn't that for Browser Detection?

Anyone know one for Operating System?

liorean
01-31-2005, 12:35 AM
If there's any data at all about the OS to be found, it'll be in the UA string. There are standard platform identifiers for many platforms. Also note that not all of these actually tell you anything. Some browsers don't distinguish between Mac or Linux on PPC. Some browsers don't distinguish between Mac Classic and Mac OS X. Some browsers don't distinguish between different Windows versions. Most X11 browsers are indifferent about what platform X11 is run upon. Some browsers tell you exactly what you want to know. In general, Windows browsers give much better data about the platform than others do.

Willy Duitt
01-31-2005, 01:36 AM
Isn't that for Browser Detection?

Anyone know one for Operating System?

Try Google.com if your search feature is broke... :rolleyes:

.....Willy

glenmac
01-31-2005, 06:53 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<SCRIPT LANGUAGE="JavaScript">

<!--
function checkOS() {
if(navigator.userAgent.indexOf('IRIX') != -1)
{ var OpSys = "Irix"; }
else if((navigator.userAgent.indexOf('Win') != -1) &&
(navigator.userAgent.indexOf('95') != -1))
{ var OpSys = "Windows95"; }
else if(navigator.userAgent.indexOf('Win') != -1)
{ var OpSys = "Windows"; }
else if(navigator.userAgent.indexOf('Mac') != -1)
{ var OpSys = "Macintosh"; }
else { var OpSys = "other"; }
return OpSys;
}
// -->

</SCRIPT>


</head>
<body >
<script>
<!--
var OpSys = checkOS();
document.write(OpSys);
//-->
</script>


</body>
</html>

Puffin the Erb
01-31-2005, 08:14 PM
What do you need the information for? Statistics gathering?

Don't make the capturing of this information mission-critical to the functionality of the script as useragent strings are easily spoofed.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum