can you detect an operating system?

Results 1 to 2 of 2

Thread: can you detect an operating system?

  1. #1
    Join Date
    Dec 1969

    Default can you detect an operating system?

    Our site runs fine on a PC - but is displayed differently on a mac. Is there a way of detecting which operating system the client is using (in a similar way to how you detect a browser maybe?)

  2. #2
    Tom Levesque Guest

    Default RE: can you detect an operating system?

    The navigator object has several properties you can access. One of them is userAgent which returns some information about the client&#039s system. In Internet Explorer the userAgent variable looks something like this:<BR><BR>Mozilla/4.0 (compatible; MSIE 5.01; Windows 98; AtHome0107)<BR><BR>In Netscape it looks something like this:<BR><BR>Mozilla/4.73 [en] (Win98; U)<BR><BR>Always count on Netscape to screw it up. Anyway you&#039ll notice that they can vary a lot but you can at least rely on the phrase "Win" to be in there somewhere if it&#039s a Windows OS. Thus, to detect if it&#039s windows or not windows, use this code:<BR><BR>var operating_system = navigator.userAgent;<BR><BR>if (operating.system.indexOf("Win") &#062; -1){<BR><BR>alert("Ahh, hello experienced Microsoft programmers, welcome to my website");<BR><BR>}else{<BR><BR>alert("Eek, its Steve Jobs, run for your life!");<BR><BR>}<BR><BR>Hope this helps.

Posting Permissions

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