I operate a website in which I would like to be able to advertise an downloadable program for windows only.
- The advert for this will lie inside a div called 'adforwindows'.
- I would like to use a detection method similar to the one listed here: http://www.javascripter.net/faq/operatin.htm
Summary:
If Operating System = Windows
Then set visibility of Div 'adforwindows' to visible
Else Set visibility of Div 'adforwindows' to hidden
Does anyone know a good html/javascript script that can do this?
EDIT
Is this a solution? Can't seem to get it to work;
<!DOCTYPE html>
<html>
<head>
<script>
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";
}
</script>
</head>
<body>
<div class="adforwindows">
Windows Advert
</div>
<p>Main site content<P>
</body>
</html>