gpt4 book ai didi

javascript - 排除 MacOS

转载 作者:行者123 更新时间:2023-11-29 09:59:37 30 4
gpt4 key购买 nike

如果检测到某个操作系统,是否有一种简单的方法可以排除某些代码?

我设计了一个运行良好的网站(它是一个 sidescroller),当使用滚轮(向上/向下)时,它会左右滚动。但是,如果您使用的是 MacOS 笔记本电脑,并且用两根手指向侧面滑动,它就会开始来回抖动。有没有办法排除这一小段横向滚动 javascript?

最佳答案

您可以使用 navigator.platform 属性

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

navigator.platform 的返回类型是:"Win32"、"Linux i686"、"MacPPC"、"MacIntel"、"Other"

所以你可以这样做:

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
}

关于javascript - 排除 MacOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4159992/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com