是否有可能检测到三星股票浏览器

问题描述 投票:8回答:4

因为三星股票浏览器的画布bug,我的程序会导致错误。 (http://code.google.com/p/android/issues/detail?id=39247

所以我想在所有三星股票浏览器上禁用画布。

我可以通过导航器对象或其他方式检测到它吗?

我发现了同样的问题,但它的解决方案看起来并不完美(javascript - regex matching devices on user agent

Wiki显示三星拥有更多型号。 (http://en.wikipedia.org/wiki/Samsung_Galaxy_S_III

javascript canvas android-browser navigator
4个回答
5
投票

你可以这么做

var isSamsungBrowser = navigator.userAgent.match(/SamsungBrowser/i)

3
投票

以下正则表达式几乎涵盖了所有三星移动设备。

if(navigator.userAgent.match(/SAMSUNG|Samsung|SGH-[I|N|T]|GT-[I|N]|SM-[A|N|P|T|Z]|SHV-E|SCH-[I|J|R|S]|SPH-L/i)) {
    console.log("it's Samsung");
    // your code for Samsung Smartphones goes here...
}

0
投票

使用userAgent就足以检测到这个bug。寻找字符串534.30。例如:

  if (window.navigator && window.navigator.userAgent.indexOf('534.30') > 0) {
    // Clear the canvas a different way because they are using a known-bad version of the default android browser
  }

0
投票

一些三星用户代理商中有“三星”这个词。如果您在用户代理字符串中找到“samsung”,那么它就是一个很好的指标。但是,我看过的大多数三星用户代理都没有包含三星这个词。但是有一个不同的检查,所有三星型号(到目前为止)的格式为“GT-xxxxxx”,所以我们检查用户代理有“android”,然后在UA的某处“GT-”。 (或三星这个词......)这显然有些松懈,但到目前为止似乎抓住了它们......

© www.soinside.com 2019 - 2024. All rights reserved.