Link to home
Start Free TrialLog in
Avatar of savache27
savache27

asked on

Facebook like box not working

Hi,

I'm looking over someone's code, and they were trying to get a Facebook like box to work on their website. I even went to the Facebook page to generate the code myself and I cannot get it to work. Dreamweaver is being used to develop the site. This is the code. If I used the IFRAME code it generates then it works. Any ideas why this wouldn't work?

This is placed after the <body> tag:

<div id="fb-root"></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>

This is lower in the page where it's meant to display:

<div class="fb-like-box" data-href="http://www.facebook.com/myPage" data-width="200" data-show-faces="false" data-colorscheme="dark" data-stream="true" data-header="true"></div>

I changed the Facebook url so that I could post it here. Any help would be greatly appreciated.
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

It works in the iframe because the iframe comes directly from Facebook.  This line outside of an iframe:

  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";

Open in new window


Needs an http or https prefix to work.
Avatar of savache27
savache27

ASKER

I've tried both. In fact, I had to add the http to the iframe to get it to work.
Humph. If adding the http isn't working then maybe Faceborg is barfing up the wrong code :)

When I get to the office I can login and check my developer account and see what code I get.
LOL! :) Thanks. I think she's just going to use the iframe code. Curious as to why this isn't working, but you don't have to continue with it. I'm sure you're busy with other things. Thanks for the advice!
Okay, looking at developers.facebook.com.  The code you posted is correct as is your placement of it.  The only thing left to check is javascript conflicts.  Are other javascript libraries being called?
Yes, she has a slide show script.

Conveyor belt slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)

Maybe that's what's causing the problem.
ASKER CERTIFIED SOLUTION
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmm...I just tried that, and nothing. Maybe it is a server issue.
Thank you so much for your help.