Solved

Facebook like box not working

Posted on 2013-01-08
9
376 Views
Last Modified: 2013-01-22
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.
0
Comment
Question by:savache27
  • 5
  • 4
9 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 38754998
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.
0
 

Author Comment

by:savache27
ID: 38755041
I've tried both. In fact, I had to add the http to the iframe to get it to work.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 38755219
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.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:savache27
ID: 38756938
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!
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 38757565
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?
0
 

Author Comment

by:savache27
ID: 38759249
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.
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 38761328
Potentially.  Try making a completely new, blank page and just add the Facebook embed codes.  If that works, we most likely have a JavaScript conflict.  If the problem persists, you may be seeing the server blocking cross-site scripting as a security hazard.
0
 

Author Comment

by:savache27
ID: 38762802
Hmm...I just tried that, and nothing. Maybe it is a server issue.
0
 

Author Closing Comment

by:savache27
ID: 38807561
Thank you so much for your help.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question