Archive | April 2012

JavaScript Code : Detect Operating System (XP or Win 7)

Hey folks,

I was busy with my work but hopefully, I’m back now!!

I just wanted to check which Operating System my user have, using JavaScript Code:

<html>

<body>

<script type=”text/javascript”>

var OSName=”Unknown OS”;

var OS = navigator.appVersion;

if (OS.indexOf(“Win”) != -1)

{

if ((OS.indexOf(“Windows NT 5.1”) != -1) || (OS.indexOf(“Windows XP”) != -1))

OSName = “Win XP”;

else if ((OS.indexOf(“Windows NT 7.0”) != -1) || (OS.indexOf(“Windows NT 6.1”) != -1))

OSName = “Win 7”;

}

document.write(OSName);

</script>

</body>

</html>

Advertisements
%d bloggers like this: