Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5849837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:03:24+00:00 2026-05-22T13:03:24+00:00

I have a little web app that uses the Facebook like widget. This page

  • 0

I have a little web app that uses the Facebook like widget. This page also uses querrystrings to load content dynamically. I need the href assigned to the Facebook widget to be determined dynamically based on the querrystring. Here is an example of how I define the widget:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=186609524720286&amp;xfbml=1"></script>
<fb:like id="fbLike" href="http://apps.facebook.com/inflatableicons/image_preview.html" send="true" width="450" show_faces="true" font="">
</fb:like>

But what I really need is something like this:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=186609524720286&amp;xfbml=1"></script>
<fb:like id="fbLike" href="http://apps.facebook.com/inflatableicons/image_preview.html?y=119" send="true" width="450" show_faces="true" font="">
</fb:like>

Notice that href in the second example ends with with ?y=119 but the first one does not. My problem is that I will not know which value to put as the querrystring for the widget till I see which querrystring is passed to the html page. Can anyone explain how I could insert a dynamic value into the href? I first tried to do set the href after the fact like this:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=186609524720286&amp;xfbml=1"></script>
<fb:like id="fbLike" href="#" send="true" width="450" show_faces="true" font="">
</fb:like>
<script>
  var url = 'http://apps.facebook.com/inflatableicons/image_preview.html?y=120';
  document.getElementById('fbLike').setAttribute('href', url);
  console.log(document.getElementById('fbLike'));
</script>

but when I do this the widget complains that href is not set, strangely when I print the value of getElementById it shows the href that I set with setAttrbibute, even though the widget does not think it was set correctly and gives an error. I believe that for some reason the widget will not allow me to set the href after the fact.

EDIT:

I also tried using the jQuery example that ferni descried in his answer but this did not seem to work:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=186609524720286&amp;xfbml=1"></script>
<fb:like id="fbLike" href="#" send="true" width="450" show_faces="true" font="">
</fb:like> 
<script>
    var url = 'http://apps.facebook.com/inflatableicons/image_preview.html?y=120';
    jQuery("#fblikeblock").html('<fb:like id="fbLike" href="'+url+'" send="true" width="450" show_faces="true" font=""></fb:like>');
    FB.XFBML.parse(document.getElementById('fblikeblock'));
    console.log(document.getElementById('fblikeblock'));
  </script>

I added the console.log to the end of the script to print the value of fblikeblock and that returned null so this may be part of the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:03:25+00:00Added an answer on May 22, 2026 at 1:03 pm

    You’ll need to add the fb:like button to the page and then call the XFBML processor on it. So something like this (I’m assuming jQuery is the library in use: you’ll have to change it if you’re using something else):

    var url = "http://apps.facebook.com/inflatableicons/image_preview.html?y=119";
    jQuery("#fblikeblock").html('<fb:like id="fbLike" href="'+url+'" send="true" width="450" show_faces="true" font=""></fb:like>');
    FB.XFBML.parse(document.getElementById('fblikeblock'));
    

    EDIT: a potential implementation of this solution would be this.

    <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=186609524720286&amp;xfbml=1"></script>
    <div id="fblikeblock"></div>
    <script>
        var url = 'http://apps.facebook.com/inflatableicons/image_preview.html?y=120';
        jQuery("#fblikeblock").html('<fb:like id="fbLike" href="'+url+'" send="true" width="450" show_faces="true" font=""></fb:like>');
        FB.XFBML.parse(document.getElementById('fblikeblock'));
        console.log(document.getElementById('fblikeblock'));
      </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little pet web app project I'd like to show someone who
I have a problem with a little .Net web application which uses the Amazon
I need a little help on this subject. I have a Web application written
I have a new web app that is packaged as a WAR as part
I've been using python for years, but I have little experience with python web
I have been making a little toy web application in C# along the lines
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a little dilemma that maybe you can help me sort out. I've
I have a little game written in C#. It uses a database as back-end.
I have little knowledge of Flash but for a little Flash game I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.