Solved

Facebook like box not working

Posted on 2013-01-08
9
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

726 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