Mobile app version of vmapp.org
Login or Join
Gloria169

: Why does XFBML work everywhere but in Chrome? I try to add simple Like button to my Facebook Canvas app (iframe). The button (and all other XFBML elements) works in Safari, Firefox, Opera,

@Gloria169

Posted in: #FacebookApplication #GoogleChrome #Javascript

I try to add simple Like button to my Facebook Canvas app (iframe). The button (and all other XFBML elements) works in Safari, Firefox, Opera, but in Google Chrome.

How can I find the problem?

EDIT1:

This is ERB-layout in my Rails app

<html xmlns:fb='http://www.facebook.com/2008/fbml' xmlns='http://www.w3.org/1999/xhtml'>
...
<body>
...
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<%= @app_id %>', status: true, cookie: true, xfbml: true
});
FB.XFBML.parse();
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js#appId=<%=@app_id%>&amp;amp;xfbml=1';
document.getElementById('fb-root').appendChild(e);
}());
FB.XFBML.parse();
</script>
<fb:like></fb:like>
...


JS error message in Chrome inspector:

Uncaught ReferenceError: FB is not defined
(anonymous function)
Uncaught TypeError: Cannot call method 'appendChild' of null
window
(anonymous function)


Probably similar to forum.developers.facebook.net/viewtopic.php?id=84684

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gloria169

1 Comments

Sorted by latest first Latest Oldest Best

 

@Fox8124981

I'm doing exaclty what you are doing. And it works. Try this snippet.

<div id="fb-root"></div>

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

<script>

FB.init({appId: '<%= @app_id %>', status: true, cookie: true, xfbml: true});

FB.Event.subscribe('auth.sessionChange', function(response) {

if (response.session) {

// A user has logged in, and a new cookie has been saved

} else {

// The user has logged out, and the cookie has been cleared

}

});

</script>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme