Facebook like button showing in Firefox but not showing in IE
Asked Answered
K

4

9

I have a Facebook like button on my page using the XBFML tag. I think the code is working, because it works in Firefox without a problem.

But in IE 8 (running in IE 7 compliant mode), the button does not show at all.

If I switch it all to the iFrame version of the like button it all works. But when I go with the XBFML tag it does not work.

Anyone run into anything like this?

Kinesics answered 2/6, 2010 at 13:8 Comment(0)
F
18

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.

Farrahfarrand answered 2/6, 2010 at 13:11 Comment(1)
I am loading Facebook Like asynchronously, and found that adding the namespaces directly (e.g. via $('html').attr('xmlns:fb', 'http://www....')) didn't work. I'm debugging through Facebook's code right now and they seem to use document.namespaces to read the namespaces - and even after me adding the namespace via jQuery, document.namespaces['xmlns:fb'] returns undefined.Cookhouse
W
3

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.

Wetzell answered 6/7, 2010 at 18:2 Comment(0)
F
1

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.

Faggot answered 7/7, 2011 at 22:22 Comment(0)
E
0
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!

Ezara answered 9/1, 2012 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.