I'm using code similar to below:
var image = new Image();
image.src = "http://youtube.com/favicon.ico";
image.onload = function(){
// The user can access youtube
};
image.onerror = function(){
// The user can't access youtube
};
Which I found here: Detecting if YouTube is blocked by company / ISP
To test if a user has access to youtube/facebook/twiter, so when I try to embed a video, or a like button. I know if the user can see it. At my workplace whenever I go to a website that uses a like/tweet button etc, I see a small portion of an ugly page telling me that the content is blocked on our network. I don't want the people visiting my site to see this.
The above code works fine for me on my network. But what methods can I use to test it to make sure it will work for everyone, and if it doesn't what code would, as every workplace/network blocks content differently.
Thanks for any answers.
What you're doing is the best you can get. You answered yourself partly when you mentioned that "every workplace/network blocks content differently". For all you know, the mediating proxy could return a valid webpage or image when you try to request a blocked resource. This wouldn't be an error condition but obviously it also wouldn't be the content that you were expecting. There is no "sure" way to tell if the returned content is correct or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With