Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Facebook like box not working

Posted on 2013-01-08
9
Medium Priority
?
383 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

610 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