There are 2 cases:
1) I am loading JS file from facebook site by using script tag.If this site is blocked by network access manager (websense) we are getting 302 response and autmatically redirected to some page. How to handle t开发者_开发技巧his condition ?
2) if point #1 passes then it internally creates an IFrame and try to access another facebook site now if this is blocked then same thing will happen but this time some text will appear on page along with other Page content visible to user. How to handle this ?
Please help me out here.
Regards, PV
The easiest way to handle the first case is to check for a variable or namespace loaded by the javascript from Facebook.
// lets assume the facebook js file contains a "fb" namespace
if(fb || window.fb){
// do some action since we have facebook loaded
var fbFrame = document.getElementsByTagName('iframe')[0];
fbFrame.onerror = function(){
// facebook failed to load :( do redirect
window.location.href = "someOtherPage.html";
};
}else{
// facebook failed to load :( do redirect
window.location.href = "someOtherPage.html";
}
For the second part, you can add an onerror event listener to the iframe. When an error occurs loading the iframe, the onerror handler will be invoked.
Here's a good question that covers it: How can I handle errors in loading an iframe?
精彩评论