Exclude if MacOS

Is there an easy way to exclude specific code if a specific OS is detected?

I developed a site that works great (it's scrolling), when using scrollwheel (up / down) it scrolls sideways. But if you're on a MacOS laptop and you make two fingers to the side, it starts to tremble back and forth. Is there any way to exclude this small side-javascript snippet?

+3
source share
1 answer

You can use the navigator.platform property

document.write("Platform: " + navigator.platform);

Return types for navigator.platform: "Win32", "Linux i686", "MacPPC", "MacIntel", "Other"

So you can do something like:

if(navigator.platform != "MacPPC" && navigator.platform != "MacIntel")
{
    // put scrolling stuff here
    // you actually don't need the MacPPC check 
    // b/c the laptops with swiping are all Intel based I believe
}
+5
source

Source: https://habr.com/ru/post/1774410/


All Articles