Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find User's Operating System

    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

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    This information is usually supplied in the HTTP headers, and can be retrieved directly with PHP.

  • #3
    Regular Coder
    Join Date
    Jan 2005
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried looking for a php script to find this, but I didn't see any?

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by techgearfree
    I tried looking for a php script to find this, but I didn't see any?

    HTTP_USER_AGENT

  • #5
    Regular Coder
    Join Date
    Jan 2005
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Isn't that for Browser Detection?

    Anyone know one for Operating System?

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by techgearfree
    Isn't that for Browser Detection?

    Anyone know one for Operating System?
    Try Google.com if your search feature is broke...

    .....Willy

  • #8
    Regular Coder
    Join Date
    Nov 2003
    Location
    Vancouver Island Canada
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    This may get you started

    Code:
    <!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>

  • #9
    Regular Coder
    Join Date
    Oct 2004
    Posts
    168
    Thanks
    0
    Thanked 5 Times in 5 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •