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

Tags: , , , , , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: