检测YouTube是否被公司/ ISP阻止 [英] Detecting if YouTube is blocked by company / ISP

查看:173
本文介绍了检测YouTube是否被公司/ ISP阻止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在某个网站上放置了YouTube视频,并希望检查是否有可能由于(大多数情况下)公司政策或其他原因而无法查看这些视频。



我们有两个站点:$ b​​
$ 1)Flex / Flash
2)HTML

我想用Flex我可以尝试下载 http://youtube.com/crossdomain.xml ,如果它是有效的XML假设该网站是可用的



但与HTML我不知道该怎么做。我甚至不能想到一个很好的黑客。

解决方案

我喜欢缺乏解决方案,但是, a href =http://en.wikipedia.org/wiki/Race_condition =noreferrertitle =维基百科竞赛条件>竞赛条件。
这将工作,不会创建一个竞赛的关系:

  var image = new Image(); 
image.onload = function(){
//用户可以访问youbube
};
image.onerror = function(){
//用户不能访问youbube
};
image.src =http://youtube.com/favicon.ico;


We have YouTube videos on a site and want to detect if it is likely that they will not be able to view them due to (mostly likely) company policy or otherwise.

We have two sites:

1) Flex / Flash 2) HTML

I think with Flex I can attempt to download http://youtube.com/crossdomain.xml and if it is valid XML assume the site is available

But with HTML I don't know how to do it. I can't even think of a 'nice hack'.

解决方案

I like lacker's solution, but yes, it creates a race condition. This will work and won't create a race contition:

var image = new Image();
image.onload = function(){
// The user can access youtube
};
image.onerror = function(){
// The user can't access youtube
};
image.src = "http://youtube.com/favicon.ico";

这篇关于检测YouTube是否被公司/ ISP阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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