I like to know if we can detect with JS (Ajax for example), the blocking of a website in a network (eg Youtube). The idea is whether Youtube is blocked I display an image instead of video.
thank you,
In ajax you could catch error from the link and act in such cases. In most cases when a site is blocked you will get an timeout, having this in mind here is an example of handling such cases:
$.ajax({
url: "/some/youtube/url/",
type: "GET",
timeout: 1000,
success: function(response) {
// Site is not blocked
alert(response);
},
error: function(x, t, m) {
// Site is blocked probably
if(t==="timeout") {
alert("got timeout");
} else {
alert(t);
}
}
});