Sunday, October 31, 2010

Finding out operating system through javascript

For finding out operating system through javascript you will need to add

<script type="text/javascript">
  function findOS (  )  {
    var ua = navigator.userAgent.toLowerCase (  ) ;
    if  ( ua.indexOf ( "win" )  != -1 )  {
      return "Windows";
    } else if  ( ua.indexOf ( "mac" )  != -1 )  {
      return "Macintosh";
    } else if  ( ua.indexOf ( "linux" )  != -1 )  {
      return "Linux";
    } else if  ( ua.indexOf ( "x11" )  != -1 )  {
      return "Unix";
    } else {
      return "Computers";
  }
}
</script>

in the head section and in body just add :

<script type="text/javascript">
  document.write ( findOS (  )  ) 
</script>
for more solutions you can visit java2s.com

No comments:

Post a Comment