0

I have some video features on a HTML web page unsupported by <=iOS12 and <=macOS 10.14.

I know redirecting the visitor isn't an ideal solution but could someone please help me with the javascript to detect OS version and redirect to an alternate page?

Many thanks in advance

Edit: Thank you everyone for your replies, could someone please advise how I can add the OS version to the following script and not just detect the OS?

if (navigator.appVersion.indexOf("Mac")!=-1) window.location="http://xxx.url";
</script>
Lewis
  • 9
  • 2
  • 1
    Why does the platform matter? Surely it matters what browser they're using? --- Even so, the platform can be extracted from the [user agent string](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) – evolutionxbox Apr 12 '21 at 09:32
  • Please refer this https://stackoverflow.com/questions/38241480/detect-macos-ios-windows-android-and-linux-os-with-js – JSN Apr 12 '21 at 09:36
  • Does this answer your question? [Detect MacOS, iOS, Windows, Android and Linux OS with JS](https://stackoverflow.com/questions/38241480/detect-macos-ios-windows-android-and-linux-os-with-js) – evolutionxbox Apr 12 '21 at 09:40
  • Does this answer your (edited) question? [How to find the operating system version using JavaScript?](https://stackoverflow.com/questions/9514179/how-to-find-the-operating-system-version-using-javascript) – evolutionxbox Apr 12 '21 at 10:24

1 Answers1

1

A lot of related information may be retrieved via globally availble navigator object.

Property platform tells you the general type of the OS, for example "MacIntel" or "Win32".

Then you can also use the userAgent property and try to parse the exact version of the OS:

const { platform, userAgent } = window.navigator;

console.log(platform); // MacIntel
console.log(userAgent); // Parse it and find the version
Artem Arkhipov
  • 7,025
  • 5
  • 30
  • 52