How to make a static web page that suggests the right Electron build to download based on visitor's operating system? #494
-
What I'd like to do:
Do you know any template, library or any kind of existing code that I could use to do that quickly and not spend too much time fixing bugs? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Wordpress Desktop seems to do it: var OSName = "os-unknown";
if ( window.navigator.userAgent.indexOf( "Windows" ) != -1 ) OSName = "os-windows";
if ( window.navigator.userAgent.indexOf( "Mac") != -1 && !isMobile ) OSName = "os-osx";
if ( window.navigator.userAgent.indexOf( "Linux") != -1 ) OSName = "os-linux";
document.getElementsByTagName( 'html' )[0].className += " " + OSName;
function menu() {
var menu = document.getElementById( 'menu-header' );
menu.style.display = menu.style.display ? "" : "block";
} ... but does not seem to make a difference between win32 and win64. |
Beta Was this translation helpful? Give feedback.
-
You can do this, but ensure that you have a "Need another platform?" button as well in case the detection doesn't work or people are faking their user agents. The basic strategy is just to sniff out the OS from |
Beta Was this translation helpful? Give feedback.
-
Thanks @MarshallOfSound, I totally agree! And thanks for the link. Do you think that I can safely use the |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Thanks for sharing this! |
Beta Was this translation helpful? Give feedback.
You can do this, but ensure that you have a "Need another platform?" button as well in case the detection doesn't work or people are faking their user agents.
The basic strategy is just to sniff out the OS from
navigator.userAgent
.See https://stackoverflow.com/questions/9514179/how-to-find-the-operating-system-version-using-javascript