在不使用用户代理字符串的情况下检测Google TV [英] Detect Google TV without using user agent string

查看:129
本文介绍了在不使用用户代理字符串的情况下检测Google TV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个客户希望他们的内容在Google TV上(通过Chrome浏览器),但在法律上限制在常规网络上允许它。所以我们希望通过Javascript检测Google TV浏览器,如果不是,则禁止播放内容。

We have a client that wants their content on Google TV (via the Chrome Browser), but is legally restricted from allowing it on the "regular web". So we want to detect Google TV Browser via Javascript, and if it is not, disallow playing the content.

首先想到的是检查用户代理字符串,但显然他们不喜欢这样,因为用户在网络浏览器上更改用户代理字符串太容易了,所以它假装是Google TV浏览器。

The first thought was to check the user agent string, but apparently they don't like that because it would be too easy for a user to change their user agent string on their web browser so it pretends to be the Google TV browser.

还有其他我们可以检查的东西有点难(或至少不那么明显)假吗?我知道任何解决方案都可以被黑客攻击,如果有人努力,那没关系。

Is there something else we could check for that is a little harder (or at least less obvious) to fake? I know any solution can be hacked around if someone tries hard enough, and that is ok.

推荐答案

你可能有些事情可以这样做,因为您只想确保使用GoogleTV浏览器检测谁。当然这些可能是欺骗性的,但它们比使用不同的用户代理字符串要困难得多。

There may be some things you can do since you only want to ensure that you are detecting who is NOT using a GoogleTV browser. Certainly these can be spoofed but they are quite a bit harder than just using a different user-agent string.

基本上,想法是测试某些JavaScript对象支持(参见此页: http://www.javascriptkit.com/javatutors/objdetect3.shtml对于一些想法)。这方面的一个例子是测试是否存在 window.opera ,这表明浏览器确实是Opera,绝对不是GoogleTV。

Basically, the idea would be to test for certain JavaScript object support (see this page: http://www.javascriptkit.com/javatutors/objdetect3.shtml for some ideas). An example of this would be testing for the presence of window.opera which would indicate that the browser was indeed Opera and definitely NOT a GoogleTV.

为此,我编写了一个小小提琴示例,在所有现代浏览器中都不能被用户代理切换伪造,并且需要更复杂的机制来绕过。我测试了它确实传递了Google TV。

To that end, I've written a small fiddle example that cannot be faked by user-agent switching in all the modern browsers and requires a more sophisticated mechanism to bypass. I tested and it does pass on a Google TV.

http://jsfiddle.net/XBT4w/2 /

这篇关于在不使用用户代理字符串的情况下检测Google TV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆