<script> osName = 'Unknown'; function nav(x, y, z) { z = z || y; if (navigator[x] && navigator[x].indexOf(y) !== -1) { osName = z; } } nav( "appVersion", "X11", "UNIX" ); nav( "appVersion", "Mac", "MacOS" ); nav( "appVersion", "Linux" ); nav( "userAgent", "Linux" ); nav( "platform", "Linux" ); nav( "appVersion", "Win", "Windows" ); nav( "userAgent", "Windows" ); nav( "platform", "Win", "Windows" ); nav( "oscpu", "Windows" ); document.getElementById("download"+osName).className = "knownOS"; </script>
Make sure that the correct download link is easy to find, but does not hide other links to the OS. People may still want them.
<style> #downloadUNIX, #downloadMacOS, #downloadLinux, #downloadWindows { color:#6D94F2; line-height:35px; margin:24px 0 24px 0; padding:10px; } .knownOS { background-color:#F7ECAD !important; border:2px solid #E8913A; color:#133CC4 !important; font-weight:bold; } </style>
And some html
<ul> <li><a id="downloadUNIX" href="unix Link Here" >Download Napster-9000 for UNIX</a></li> <li><a id="downloadWindows" href="windows Link Here">Download Napster-9000 for Windows</a></li> <li><a id="downloadMacOS" href="mac os link here" >Download Napster-9000 for OS X</a></li> <li><a id="downloadLinux" href="linux Link Here" >Download Napster-9000 for Linux</a></li> </ul>
Now the user can disable or block javascripts if he wants. Links will still be present, not writing links with Javascript, which requires javascript to work.
Here is the fiddle
http://jsfiddle.net/7fmJb/
gaby de wilde Jan 06 '14 at 7:37 2014-01-06 07:37
source share