0

The code i have works fine with detecting the Os on mac and on my windows pc at home but for some reason the windows pc at my internship detects MacOs. Also on my android it downloads and detects the linux version.

console.log("werkt")
jQuery('.LeButton').click(function() {
  console.log(".LeButton")
  var OSName = "Unknown OS";
  console.log(navigator.appVersion);
  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 (navigator.appVersion.indexOf("Andoid") != -1) OSName = 'Android';
  if (navigator.appVersion.indexOf("Linux a") != -1) OSName = 'Android';
  if (navigator.appVersion.indexOf("null") != -1) OSName = 'Android';
  if (navigator.appVersion.indexOf("iPhone") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("iPod") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("iPhone Simulator") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("MacPPC") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("Mac68K") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("Pike") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("Macintel") != -1) OSName = 'Ios';
  if (navigator.appVersion.indexOf("MacIntel") != -1) OSName = 'Ios';
  if (OSName == "MacOs") {
    window.location = 'https://get.anydesk.com/algsS7Tu/Develto_AnyDesk.dmg';
  } else if (OSName == "Windows") {
    window.location = 'https://get.anydesk.com/rWkVpCDA/Develto_AnyDesk.exe';
  } else if (OSName == "Linux") {
    window.location = 'https://get.anydesk.com/FAYb0MAc/Develto_AnyDesk.tar.gz';
  } else if (OSName == "Android") {
    window.location = 'https://get.anydesk.com/7LUtiVEA/AnyDesk.apk';
  } else if (OSName == "Ios") {
    window.location = 'https://itunes.apple.com/us/app/anydesk/id1176131273';
  }
  console.log(OSName)
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<button class="LeButton">Go to download page </button>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • And what have you tried to resolve the problem? Where are you stuck? – Nico Haase Sep 07 '21 at 07:37
  • 2
    _*Navigator.appVersion*: Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time._ – mplungjan Sep 07 '21 at 07:41
  • I added `console.log(navigator.appVersion);` Run it on the PC windows you have issues with and report the result – mplungjan Sep 07 '21 at 07:43
  • I see that navigator.platform is also deprecated but it is the current best bet – mplungjan Sep 07 '21 at 07:48

0 Answers0