【问题标题】:How to detect (from website) whether ipad is using a Safari or non Safari (wrapper) browser?如何(从网站)检测 ipad 使用的是 Safari 还是非 Safari(包装)浏览器?
【发布时间】:2015-08-14 21:42:45
【问题描述】:

在 iPad (2+) 上 Chrome 浏览器(它是原生 Safari 浏览器 AFAIK 的封装)不会触发某些事件(例如当用户关闭浏览器时)。这会导致误报“应用已崩溃”报告。

所以我们想从某种包装器中过滤掉正在使用 Safari 的用户。

有什么方法可以检测到(相对容易)?

堆栈:PhP、.JS、jQuery

【问题讨论】:

  • 看看用户代理字符串。

标签: ios safari ipad-2 ipad-3 ipad-mini


【解决方案1】:

您可以通过浏览器的用户代理 (UA) 字符串访问此类信息。 试着看看这个: https://developer.chrome.com/multidevice/user-agent

据此,可以过滤掉 Safari 用户:

if(navigator.userAgent.match('Version')) {
    // Insert logic here 
}

而 iOS 用户的 Chrome 可能会被过滤掉:

if(navigator.userAgent.match('CriOS')) {
    // Insert logic here 
}

【讨论】:

    猜你喜欢
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 2011-08-25
    相关资源
    最近更新 更多