title: Show or Hide Div based on OS
body: <p>I operate a website in which I would like to be able to advertise an downloadable program for windows only. </p>
  
  <ul>
  <li>The advert for this will lie inside a div called 'adforwindows'.</li>
  <li>I would like to use a detection method similar to the one listed here: <a href="http://www.javascripter.net/faq/operatin.htm" rel="nofollow">http://www.javascripter.net/faq/operatin.htm</a></li>
  </ul>
  
  <p>Summary:  </p>
  
  <pre><code>If Operating System = Windows
  </code></pre>
  
  <p><code>Then set visibility of Div 'adforwindows' to visible</code><br> <code>Else Set visibility of Div 'adforwindows' to hidden</code></p>
  
  <p>Does anyone know a good html/javascript script that can do this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Is this a solution? Can't seem to get it to work;</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  var OSName="Unknown OS";
  if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
  if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
  if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
  if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
  
  if(OSName == "Windows"){
     document.getElementById('adforwindows').style.visibility = "visible";
  }
  else{
     document.getElementById('adforwindows').style.visibility = "hidden";
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="adforwindows"&gt;
  Windows Advert 
  &lt;/div&gt;
  &lt;p&gt;Main site content&lt;P&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>