Solved

Facebook like box not working

Posted on 2013-01-08
9
378 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display recordset field HTML encoded 21 55
MVC and Angular 2 114
Getting attribute Values using xslt 4 53
Create animated movies for web page 18 85
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
The viewer will learn how to dynamically set the form action using jQuery.
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…

856 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