use*_*393 0 javascript iphone safari ipad ios
在 IOS 中,我现在有以下 UserAgent:
“Mozilla/5.0(Macintosh;Intel Mac OS X 10_15_6)AppleWebKit/605.1.15(KHTML,如 Gecko)版本/15.2 Safari/605.1.15”
在我的 PC 上的 Safari 上,我有以下内容:
“Mozilla/5.0(Macintosh;Intel Mac OS X 10_15_7)AppleWebKit/605.1.15(KHTML,如 Gecko)版本/15.1 Safari/605.1.15”
但我需要检测我的脚本是否在 iPad 或 iPhone 上运行,因为我需要安装 MobileDragDrop Polyfill ( https://github.com/timruffles/mobile-drag-drop )
StackOverflow 上关于此问题的所有答案均在 IOS 15 之前,导航器属性是否仍包含“iPad”或“iPhone”
经过更多研究,我发现这可能有效:
navigator.maxTouchPoints && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')
但也许有更好的解决方案。
归档时间: |
|
查看次数: |
1704 次 |
最近记录: |