Displaying the OS name/version and the browser name/version on the page?
<p>Is it possible to display the OS name and version on the page with JavaScript? </p>

<p>I am currently using this:</p>

<pre><code>function detectOSAndBrowser() {
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var nameOffset,verOffset,ix;

// In Opera, the true version is after "Opera" or after "Version"
if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
 browserName = "Opera";
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "Internet Explorer";
}
// In Chrome, the true version is after "Chrome" 
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
 browserName = "Google Chrome";
}
// In Safari, the true version is after "Safari" or after "Version" 
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
 browserName = "Safari";
}
// In Firefox, the true version is after "Firefox" 
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
 browserName = "Mozilla Firefox";
}
// In most other browsers, "name/version" is at the end of userAgent 
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) &lt; (verOffset=nAgt.lastIndexOf('/')) ) 
{
 browserName = nAgt.substring(nameOffset,verOffset);

 if (browserName.toLowerCase()==browserName.toUpperCase()) {
  browserName = navigator.appName;
 }
}
var OSName = "unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) { 
OSName="Windows";
}
if (navigator.appVersion.indexOf("Mac")!=-1) {
OSName="Mac OS X";
}
if (navigator.appVersion.indexOf("X11")!=-1) {
OSName="UNIX";
}
if (navigator.appVersion.indexOf("Linux")!=-1) {
OSName="Linux";
}
if (OSName!=="unknown OS") {
$('#device').html('You\'re using '+browserName+'&lt;br /&gt;&lt;div id="OS"&gt;on a '+OSName+' computer.&lt;/div&gt;');
}
if (OSName=="unknown OS") {
$('#device').html('We were unable to detect your OS and/or browser.');
}
</code></pre>

<p>It works, but I want to display the version of the OS and Browser too. This is how it looks right now when I view it:</p>

<p><img src="http://i.stack.imgur.com/sG37W.png" alt="Screenshot"></p>

<p>How could I make it display the version of the browser and OS also?</p>
