Javascript Facebook图形调用在Internet Explorer 9中不起作用
我有一个JavaScript函数,用来调用Facebook API并从墙上获取帖子列表。在Firefox、Chrome和Safari中,这没有问题,但在InternetExplorer9(我还没有在下面测试过)中,它什么也不做,UI保持阻塞状态,但我似乎没有收到任何指向错误的消息。我有一种感觉,它可能与返回的JSON和InternetExplorer解析器有关,但目前我不能确定 在回到Facebook SDK之后,我用它重新实现了它(我不知道为什么我以前离开了它),现在它似乎与InternetExplorer配合得很好 旧代码Javascript Facebook图形调用在Internet Explorer 9中不起作用,javascript,facebook,internet-explorer,Javascript,Facebook,Internet Explorer,我有一个JavaScript函数,用来调用Facebook API并从墙上获取帖子列表。在Firefox、Chrome和Safari中,这没有问题,但在InternetExplorer9(我还没有在下面测试过)中,它什么也不做,UI保持阻塞状态,但我似乎没有收到任何指向错误的消息。我有一种感觉,它可能与返回的JSON和InternetExplorer解析器有关,但目前我不能确定 在回到Facebook SDK之后,我用它重新实现了它(我不知道为什么我以前离开了它),现在它似乎与InternetE
var getFeed = function (name, type, limit, accessToken, apiKey, containerId) {
var list_url = "https://graph.facebook.com/" + name + "/" + type + "?limit=" + limit + "&access_token=" + accessToken + "&api_key=" + apiKey;
var html = "";
displayHelper.blockUI(containerId, "Loading Feed");
$.getJSON(list_url, function (json) {
//Loop through and within the data array to retrieve the variables.
$.each(json.data, function (i, fb) {
var msg = (typeof (fb.message) != "undefined") ? fb.message : "";
var link = (typeof (fb.link) != "undefined") ? fb.link : "";
var pic = "";
// msg = (typeof(fb.story) != "undefined") ? fb.story : msg;
var type = (typeof (fb.type) != "undefined") ? fb.type : "";
var includeInOutput = true;
pic = getPicture(fb.from.id);
switch (type) {
case "story":
msg = fb.story;
break;
case "link":
if (typeof (fb.message) != "undefined")
msg = fb.message;
else if (typeof (fb.caption) != "undefined")
msg = fb.caption;
else if (typeof (fb.story) != "undefined")
msg = fb.story;
else if (typeof (fb.name) != "undefined")
msg = fb.name;
break;
case "video":
case "photo":
if (typeof (fb.message) != "undefined")
msg = fb.message;
else if (typeof (fb.story) != "undefined")
msg = fb.story;
break;
case "status":
if (typeof (fb.message) != "undefined")
msg = fb.message;
else if (typeof (fb.story) != "undefined")
msg = fb.story;
break;
default:
includeInOutput = false;
break;
}
if (includeInOutput) {
//build html for this list item
html += '<dl class="fb-item">';
html += "<dt>" + fb.from.name + "</dt>";
html += (pic != '') ? '<dd class="img"><img src="' + pic + '" />' : '';
html += '<dd class="msg">' + msg + '</dd>';
/*html += '<a href="' + link + '" class="fb_link" target="_blank">'
+ msg + "(" + type + ")"
+ "</a>";*/
html += '<dd class="links">';
html += '<span>' + fuzzyTime(fb.created_time.replace(/-/g, '/')) + '</span>';
if (typeof (fb.actions) != "undefined") {
if (fb.actions[1].name == "Like")
html += "<a href='" + fb.actions[1].link + "' class='fb_link' target='_blank'>Like</a> - ";
if (fb.actions[0].name == "Comment")
html += "<a href='" + fb.actions[0].link + "' class='fb_link' target='_blank'>Comment</a>";
}
html += '</dd>';
html += "</dl>";
}
}); /* end .each */
//html += "</ul>";
$(containerId).html(html);
$(containerId).unblock();
}); /* end getJSON */
} /* end hetFeed
var getFeed=function(名称、类型、限制、accessToken、apiKey、containerId){
变量列表\u url=”https://graph.facebook.com/“+name+”/“+type+”?limit=“+limit+”&access_-token=“+accessToken+”&api_-key=“+apiKey;
var html=“”;
blockUI(containerId,“加载提要”);
$.getJSON(列表、url、函数(json){
//在数据数组中循环以检索变量。
$.each(json.data,函数(i,fb){
var msg=(typeof(fb.message)!=“未定义”)?fb.message:”;
var link=(typeof(fb.link)!=“未定义”)?fb.link:”;
var pic=“”;
//msg=(typeof(fb.story)!=“未定义”)?fb.story:msg;
变量类型=(typeof(fb.type)!=“未定义”)?fb.type:”;
var includeInOutput=true;
pic=getPicture(fb.from.id);
开关(类型){
案例“故事”:
msg=fb.story;
打破
案例“链接”:
if(类型(fb.message)!=“未定义”)
msg=fb.message;
else if(typeof(fb.caption)!=“未定义”)
msg=fb.caption;
else if(typeof(fb.story)!=“未定义”)
msg=fb.story;
else if(typeof(fb.name)!=“未定义”)
msg=fb.name;
打破
案例“视频”:
案例“照片”:
if(类型(fb.message)!=“未定义”)
msg=fb.message;
else if(typeof(fb.story)!=“未定义”)
msg=fb.story;
打破
案例“状态”:
if(类型(fb.message)!=“未定义”)
msg=fb.message;
else if(typeof(fb.story)!=“未定义”)
msg=fb.story;
打破
违约:
includeInOutput=false;
打破
}
如果(包括输出){
//为此列表项生成html
html+='';
html+=“”+fb.from.name+“”;
html+=(图片!=“”)?“”:“”;
html+=''+msg+'';
/*html+='”*/
html+='';
html+=''+fuzzyTime(fb.created_-time.replace(/-/g,'/'))+'';
if(类型(fb.动作)!=“未定义”){
if(fb.actions[1].name==“Like”)
html+=“-”;
if(fb.actions[0].name==“Comment”)
html+=“”;
}
html+='';
html+=“”;
}
})/*结束*/
//html+=“”;
$(containerId).html(html);
$(containerId).unblock();
});/*end-getJSON*/
}/*结束输入
新代码-再次更新。图片没有返回,所以我提取了消息并将部分构建到自己的方法中,并在获取图片的回调中构建了消息。在我以阻止方式执行之前,这是错误的!希望有一天这将帮助某人
var postMessage = function (fb, containerId) {
FB.api("/" + fb.from.id + "/?fields=picture", {}, function (p) {
var pic = p.picture;
var msg = (typeof (fb.message) != "undefined") ? fb.message : "";
var link = (typeof (fb.link) != "undefined") ? fb.link : "";
var type = (typeof (fb.type) != "undefined") ? fb.type : "";
var includeInOutput = true;
var html = "";
switch (type) {
case "story":
msg = fb.story;
break;
case "link":
if (typeof (fb.message) != "undefined")
msg = fb.message;
else if (typeof (fb.caption) != "undefined")
msg = fb.caption;
else if (typeof (fb.story) != "undefined")
msg = fb.story;
else if (typeof (fb.name) != "undefined")
msg = fb.name;
break;
case "video":
case "photo":
if (typeof (fb.message) != "undefined")
msg = fb.message;
else if (typeof (fb.story) != "undefined")
msg = fb.story;
break;
case "status":
if (typeof (fb.message) != "undefined")
msg = fb.message;
else if (typeof (fb.story) != "undefined")
msg = fb.story;
break;
default:
includeInOutput = false;
break;
}
if (includeInOutput) {
//build html for this list item
html += '<dl class="fb-item">';
html += "<dt>" + fb.from.name + "</dt>";
html += (pic != '') ? '<dd class="img"><img src="' + pic + '" />' : '';
html += '<dd class="msg">' + msg + '</dd>';
/*html += '<a href="' + link + '" class="fb_link" target="_blank">'
+ msg + "(" + type + ")"
+ "</a>";*/
html += '<dd class="links">';
html += '<span>' + fuzzyTime(fb.created_time.replace(/-/g, '/')) + '</span>';
if (typeof (fb.actions) != "undefined") {
if (fb.actions[1].name == "Like")
html += "<a href='" + fb.actions[1].link + "' class='fb_link' target='_blank'>Like</a> - ";
if (fb.actions[0].name == "Comment")
html += "<a href='" + fb.actions[0].link + "' class='fb_link' target='_blank'>Comment</a>";
}
html += '</dd>';
html += "</dl>";
}
$(containerId).append(html);
});
}
var getFeed = function (name, type, limit, accessToken, apiKey, containerId) {
var list_url = "https://graph.facebook.com/" + name + "/" + type + "?limit=" + limit + "&access_token=" + accessToken + "&api_key=" + apiKey;
var fullHtml = "";
helper.blockUI(containerId, "Loading Feed");
var path = "/" + name + "/" + type;
FB.api(path, { access_token: accessToken, api_key: apiKey, limit: limit }, function (json) {
console.log(json);
var data = json.data;
for (var i = 0, l = data.length; i < l; i++) {
var fb = data[i];
postMessage(fb, containerId);
} //End For
$(containerId).unblock();
});
} /* End getFeed */
var postMessage=函数(fb,containerId){
api(“/”+FB.from.id+“/?fields=picture”,{},函数(p){
var pic=p.picture;
var msg=(typeof(fb.message)!=“未定义”)?fb.message:”;
var link=(typeof(fb.link)!=“未定义”)?fb.link:”;
变量类型=(typeof(fb.type)!=“未定义”)?fb.type:”;
var includeInOutput=true;
var html=“”;
开关(类型){
案例“故事”:
msg=fb.story;
打破
案例“链接”:
if(类型(fb.message)!=“未定义”)
msg=fb.message;
else if(typeof(fb.caption)!=“未定义”)
msg=fb.caption;
else if(typeof(fb.story)!=“未定义”)
msg=fb.story;
else if(typeof(fb.name)!=“未定义”)
msg=fb.name;
打破
案例“视频”:
案例“照片”:
if(类型(fb.message)!=“未定义”)
msg=fb.message;
else if(typeof(fb.story)!=“未定义”)
msg=fb.story;
打破
案例“状态”:
if(类型(fb.message)!=“未定义”)
msg=fb.message;
else if(typeof(fb.story)!=“未定义”)
msg=fb.story;
打破
违约:
includeInOutput=false;
打破
}
如果(包括输出){
//为此列表项生成html
html+='';
html+=“”+fb.from.name+“”;
html+=(图片!=“”)?“”:“”;
html+=''+msg+'';
/*html+='”*/
html+='';
html+=''+fuzzyTime(fb.created_-time.replace(/-/g,'/'))+'';
如果(类型)(fb.动作)!=“未定义
var path = name + "/" + type;
var params = limit == null ? {} : { limit: limit };
FB.api(path, "post", params, function(json) {
......
});