{"id":1481,"date":"2022-08-30T15:16:53","date_gmt":"2022-08-30T15:16:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/23\/why-does-xfbml-work-everywhere-but-in-chrome-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:53","modified_gmt":"2022-08-30T15:16:53","slug":"why-does-xfbml-work-everywhere-but-in-chrome-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/why-does-xfbml-work-everywhere-but-in-chrome-collection-of-common-programming-errors\/","title":{"rendered":"Why does XFBML work everywhere but in Chrome?-Collection of common programming errors"},"content":{"rendered":"<p>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.<\/p>\n<p>How can I find the problem?<\/p>\n<p>EDIT1:<\/p>\n<p>This is ERB-layout in my Rails app<\/p>\n<pre><code>\n...\n\n...\n\n\n    window.fbAsyncInit = function() {\n      FB.init({\n        appId: '', status: true, cookie: true, xfbml: true\n      });\n      FB.XFBML.parse();\n    };\n    (function() {\n      var e = document.createElement('script'); e.async = true;\n      e.src = document.location.protocol +\n        '\/\/connect.facebook.net\/en_US\/all.js#appId=&amp;amp;xfbml=1';\n      document.getElementById('fb-root').appendChild(e);\n    }());\n    FB.XFBML.parse();\n\n\n...\n<\/code><\/pre>\n<p>JS error message in Chrome inspector:<\/p>\n<pre><code>Uncaught ReferenceError: FB is not defined\n  (anonymous function)\nUncaught TypeError: Cannot call method 'appendChild' of null\n  window\n  (anonymous function)\n<\/code><\/pre>\n<p>Probably similar to http:\/\/forum.developers.facebook.net\/viewtopic.php?id=84684<\/p>\n<ol>\n<li>\n<p>I&#8217;m doing exaclty what you are doing. And it works. Try this snippet.<\/p>\n<pre><code>\n\n\n\n\n\n  FB.init({appId: '', status: true, cookie: true, xfbml: true});\n\n  FB.Event.subscribe('auth.sessionChange', function(response) {\n\n    if (response.session) {\n\n      \/\/ A user has logged in, and a new cookie has been saved\n\n    } else {\n\n      \/\/ The user has logged out, and the cookie has been cleared\n\n    }\n\n  });\n\n\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-23 09:50:01. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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 &#8230; &#8230; window.fbAsyncInit = function() { FB.init({ appId: &#8221;, status: true, cookie: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1481","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1481"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1481\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}