简体   繁体   English

在Google Sites上检测Blackberry Browser

[英]Detect Blackberry Browser on google Sites

I'm using google calendar embedded on a Google Site. 我正在使用嵌入Google网站的Google日历。

BlackBerry users are reporting errors so I want to redirect them to another page. BlackBerry用户正在报告错误,因此我想将他们重定向到另一个页面。

I tried to add this code 我试图添加此代码

<script type="text/javascript">   
   var ua = navigator.userAgent;
   var url = "http://optimizedmobile.yoursite.com/";
   if (ua.indexOf("BlackBerry") >= 0)
   {
      if (ua.indexOf("WebKit") >= 0)
      {
         window.location = url;
      }
   }
</script>

using the instructions provided here , but it's not working. 使用此处提供说明 ,但不起作用。 I tested the code in a html file that I created and it works. 我在自己创建的html文件中测试了代码,并且可以正常工作。

So, any other ideas to include the code on the page? 那么,还有其他想法可以在页面上包含代码吗? Do you think the code is not supported by Google sites? 您认为Google网站不支持该代码吗?

Any other ideas to redirect BB users? 还有其他重定向BB用户的想法吗?

I don't know exactly which BlackBerry devices you're trying to detect. 我不知道您要检测哪些 BlackBerry设备。 Unfortunately, the answer is different for many of them. 不幸的是,对于许多人来说答案是不同的。

From this BlackBerry.com reference document , some UserAgent examples: 从此BlackBerry.com参考文档中 ,可以找到一些UserAgent示例:

User Agent in BlackBerry 10 BlackBerry 10中的用户代理

 Mozilla/5.0 (BB10; <Device Type>) AppleWebKit/537.10+ (KHTML, like Gecko) Version/<BB Version #> Mobile Safari/537.10+ 

User Agent in BlackBerry Tablet OS BlackBerry Tablet OS中的用户代理

 Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.0.0; en-US) AppleWebKit/535.8+ (KHTML, like Gecko) Version/7.2.0.0 Safari/535.8+ 

User Agent in BlackBerry 6 and BlackBerry 7 BlackBerry 6和BlackBerry 7中的用户代理

 Mozilla/5.0 (BlackBerry; U; BlackBerry AAAA; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/XXXX Mobile Safari/534.11+ 

User Agent in BlackBerry Device Software 4.2 to 5.0 BlackBerry Device Software 4.2至5.0中的用户代理

 BlackBerry9000/5.0.0.93 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179 

So, it looks to me like the exact string BlackBerry will only show up in user agents for devices with Java OS version 4.2 - 7.1. 因此,在我看来, BlackBerry只会在用户代理中显示具有Java OS版本4.2-7.1的设备的确切字符串。 And, among those, only those with OS 6.0 - 7.1 will be using the WebKit browser. 而且,其中只有OS 6.0-7.1的用户将使用WebKit浏览器。

So, I think you just need to add some more cases to your if statement, to detect all BlackBerry devices. 因此,我认为您只需要在if语句中添加更多情况,即可检测所有BlackBerry设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM