Facebook like button showing in Firefox but not showing in IE

半城伤御伤魂 提交于 2019-11-30 02:24:34

Try adding the xmlns attribute to the HTML document for the FB namespace:

xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"

This is another case where Firefox is being too forgiving vs IE.

Deb

the attribute: xmlns:fb="http://www.facebook.com/2008/fbml" is mentioned as a "must be used" in the Facebook Connect documentation. Some pointers here.

pdub23

I think I have a slightly different implementation than you, but the same general issue of not seeing my Facebook social buttons in IE only. It turned out that it was because I had put the Facebook script tag at the bottom of my page. The solution was to move

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>

so that it was before my button insertion:

<fb:like href="" send="true" layout="button_count" width="350" show_faces="true" font=""></fb:like>

Then the buttons started showing up in IE as well.

mana
if(document.namespaces) {
    //IE
    document.namespaces.add("fb", "http://ogp.me/ns#");
    document.namespaces.add("og", "http://ogp.me/ns/fb#");

    if (typeof(console) != 'undefined' && console) {
        console.log("IE: OG and FB NameSpace added");
    } else {
        //Other Browsers
        var htmlRoot = jQuery(jQuery("html").get(0));
        if(typeof(htmlRoot.attr("xmlns:fb")) == "undefined") {
            htmlRoot.attr("xmlns:og",'http://ogp.me/ns#');
            htmlRoot.attr("xmlns:fb",'http://ogp.me/ns/fb#');
            if (typeof(console) != 'undefined' && console) {
                console.log("OG and FB NameSpace added");
            }
        }
    }

do NOT put this into a $(document).ready() function!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!