brettbrewer.com

Programming + Design

Home
Access Denied error in IE with Facebook Javascrkpt SDK PDF Print E-mail
Written by Brett Brewer   
Wednesday, 12 January 2011

For anyone that's spent much time trying to implement the Facebook Javascript API on their web site, you may have come across some odd behavior or unexplained javascript errors in Microsoft Internet Explorer. One of the main causes of problems with the FB Javascript API in IE is a missing 'channelUrl' parameter in your FB.init() function call. To remedy such problems, you create a file such as "fbchannel.html" and in it you place the following contents.

<script src="http://connect.facebook.net/en_US/all.js"></script>
Then in your javascript code, where you call the FB.init() function, set up the parameters to include a channelUrl.
window.fbAsyncInit = function() {
        FB.init({
            appId: '1234567890',
            status: true, cookie: true,
            xfbml: true,
            channelUrl: document.location.protocol + '//www.mydomain.com/fbchannel.html'
        });
};
(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());

You might also want to make the script src in the fbchannel.html file dynamic so that it loads over https for any secure pages, but if you don't need to load the facebook API on any secure pages, then don't worry about it. Also, be sure that if you have a separate test domain for your test site that you switch the domain for the channelUrl on your test site or you'll get the js error there too. 
Last Updated ( Wednesday, 12 January 2011 )
 
< Prev   Next >

Search

Who's Online

We have 1 guest online

© 2017 www.brettbrewer.com
Joomla! is Free Software released under the GNU/GPL License.