I am using the comment plugin and it works fine in all browsers except for IE (7, 8, 9). The plugin displays but the iFrame's height is not expanding to display all of the comments. The comments appear to be cut off.

The canvas setting is fluid for the height, html5 tags are being used and its set to display 10 comments.

The solution I've found is to change the namespace from xmlns:fb="http://www.facebook.com/2008/fbml" to xmlns:fb="http://ogp.me/ns/fb#"

There is also an issue for the 6.x branch to change the namespace as well: #1445838: Change in xmlns:fb declaration

UPDATE: the namespace is not the problem. Skip to #6.

CommentFileSizeAuthor
#12 fb-1480868-12.patch577 bytesbschilt
#1 fb-1480868-1.patch290 bytesbschilt

Comments

bschilt’s picture

StatusFileSize
new290 bytes

here is a patch to change the namespace.

Dave Cohen’s picture

Status: Active » Fixed

Thanks for patch, just pushed to git.

bschilt’s picture

Status: Fixed » Needs review

Well shoot, changing the namespace did not fix my issue after all. For a while after I changed it my problem went away, but of course as soon as I created the patch and uploaded it, the issue returned. Might be a good idea to change the namespace back to its original state until its absolutely necessary that it needs to be changed.

Any idea why the comment plugin in IE doesn't load the height properly in IE? Here's a couple examples:
http://alms.com/alms-tv/episode/scott-sharp-fire
http://www.rightthisminute.com/video/losing-your-feet-video-games-truth-...

Each of the above URLs have multiple comments. They work fine in firefox for example. In IE, only one comment loads, or gets cropped off it the comment is too long. Reloading the same page will sometimes cause the plugin to work properly.

bschilt’s picture

Title: Comment plugin in IE is not adjusting height (namespace issue) » Comment plugin in IE is not adjusting height
Dave Cohen’s picture

Title: Comment plugin in IE is not adjusting height » Comment plugin in IE is not adjusting height (namespace issue)

Rather than ask why something doesn't work in IE, I take the other approach... pleasant surprise that anything works in IE.

bschilt’s picture

Title: Comment plugin in IE is not adjusting height (namespace issue) » Comment plugin in IE is not adjusting height
Status: Needs review » Active

There is something in the Facebook API module that is causing this issue but I'm not sure what it is yet...

For testing purposes I commented out the fb_page_alter() function so that it wouldn't print the FB javascript. I then added the code that comes directly from FB's comment plugin page in a similar fashion.

function myModule_page_alter(&$page) {
  $output = \<\<\<END
    \<div id="fb-root" class="></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));\</script\>
END;
  
  $page['page_bottom']['myModule'] = array(
    '#type' => 'markup',
    '#markup' => $output,
  );
}

Still didn't solve the issue, the same broken behavior was happening in IE. I then started disabling the various modules I was using in the Drupal for Facebook fieldset. Once I disabled the Facebook API module the comments started working properly. At this point, none of the FB modules are enabled.

I suspect that there may be an issue in the fb_ajax_event() function, but thats a guess at this point.

@Dave Cohen Any ideas on where to look or what might be causing the issue?

Dave Cohen’s picture

I don't know those modules specifically, but I know that facebook modules sometimes conflict. My advice is let modules/fb add the fb-root div and all.js to the page. Don't do it yourself, and don't allow any other module to do it. modules/fb will initialize javascript with your app's ID, the others (usually) won't.

Here's a workaround for the fb_social module: #1505274: conflict with modules/fb

You might be able to do something similar with other modules.

bschilt’s picture

Its not a module conflict issue. The only FB module I have enabled at the moment is Facebook API. I'm also not planning on adding the scripts myself, its merely for testing/debugging purposes.

I've narrowed it down to the fb.js file that is causing the IE issue. I have commented out everything in fb.js and fb_page_alter() is still not being used and is replaced by my custom function from #6.

I'll keep digging...

bschilt’s picture

I'm running out of time for today but it looks like the issue is in Drupal.behaviors.fb method. More specifically, for some reason IE will run the following chunk of code when it probably shouldn't.

if (typeof(FB) != 'undefined') {
  // Render any XFBML markup that may have been added by AJAX.
  $(context).each(function() {
    var elem = $(this).get(0);
    FB.XFBML.parse(elem);
  });
}

Commenting out the FB.XFBML.Parse(elem); line will fix the issue that IE is having upon page load. I'm still trying to figure out why IE is having issues with this.

Dave Cohen’s picture

Do you see the problem on http://www.drupalforfacebook.org/node/2371
???

bschilt’s picture

yeah the problem happens there too. I've found a simple solution and I'm rolling a patch now.

bschilt’s picture

Status: Active » Needs review
StatusFileSize
new577 bytes

Here is a patch that fixes the issue in IE 7, 8 and 9. In fb.js around line 305 you will find the code that was pasted in comment #9 above.

if (typeof(FB) != 'undefined') {

That line is testing if the FB object has been defined. For some reason in IE that object is defined but is essentially empty.

The solution I came up with is to check if the FB._apiKey is null.

if (typeof(FB) != 'undefined' && FB._apiKey != null) {
Dave Cohen’s picture

Status: Needs review » Needs work

Why do you think the FB object is any different in IE than in a quality browser? Is there any tool for troubleshooting IE javascript?

Your patch is not good. It would just prevent a Like button (for instance) from being rendered when there is no app configured. It's also normal for the _apikey to not be set the first time around, before fbAsyncInit is called.

bschilt’s picture

I'm not sure why the FB object is different between the two browsers but I do know that only the IE browsers are executing that bit during initial page load. If I reload the page, then the FB object is properly populated and comments work as expected.

IE 9 comes with the Developer Toolbar (press f12 to activate). Use this article for instructions on how to set breakpoints and watch the FB object. http://msdn.microsoft.com/en-us/library/ie/dd565625%28v=vs.85%29.aspx#_vars.

I also added in console.log statements into the fb.js code. Since IE comes with the developer toolbar, it no longer blows up when console.log is used.

That bit of code from comment #9 is used to process XFBML markup after an ajax request. Drupal.settings.fb.fb_init_settings.xfblm = false for my set up. I'm only using HTML5 tags on my site. Should there be an IF statement wrapping that code that prevents it from being executed if xfblm is false? Maybe that's a good enough fix.

Dave Cohen’s picture

I'll try to set a breakpoint next time I boot up windows. Thanks.

The bit of code from comment #9 processes XFBML. That's what we want to happen. Commenting out that line is guaranteed to break things on sites that add markup via ajax.

Drupal.settings.fb.fb_init_settings.xfblm = false because we explicitly call FB.XFBML.parse(). It doesn't prevent FBML from being parsed, just delays it.

Whatever is causing this is probably a bug in IE or in facebook's all.js. Neither company would fix that bug in a timely fashion. So if we can come up with a workaround, great. I have no idea what that workaround should be.

Dave Cohen’s picture

Issue summary: View changes

adding an update to the main issue noting that namespace is not the culprit.