Since you would already know the OS from this code (taken from website)
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";
You can thus use a simple if statement to check and document.getElementById to set the visibility.
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.display = "block";
}
else{
document.getElementById('adforwindows').style.display = "none";
}
If you do not need to know the other operating systems, just use this shorter code:
if (navigator.appVersion.indexOf("Win")!=-1)
document.getElementById('adforwindows').style.display = "block";
}
else{
document.getElementById('adforwindows').style.display = "none";
}
EDIT: if you want to have it
visibility:none/visible
instead of display:none
(there is a difference: http://www.w3schools.com/css/css_display_visibility.asp
you can change .style.display = "none";
to .style.visibility = "hidden";
and change .style.display = "block";
to .style.visibility = "visible";