Thursday, March 15, 2012

Assigning URL for Facebook Comments plugin via JavaScript

How to assign a URL for the Facebook comments plugin dynamically at run-time on the client side using some simple JavaScript.

To set your href parameter for the Facebook Comments plugin, simply add the following code.


* Thanks for the tip on how to use gist from github!

In the above code, please note that I'm using the window.fbAsyncInit. When the Facebook JavaScript SDK is loaded dynamically, Facebook will call this function once the SDK is ready to go.

Also note the use of FB.XFBML.parse(); function. This will tell the SDK to reparse the DOM for any Facebook plugin code. It doesn't matter if the code is HTML5 or XFBML, either way, the Facebook JavaScript SDK is smart enough to find either type and will insert their iframed content.

I hope this helps you along your way to making the best possible user experience on your website.
Happy coding!!

8 comments:

  1. Nice blog i like this post i am looking for such information long time & finally i got it from this post,Thanks for sharing this.
    Feel Free To Surf My Website - Gurgaon Escorts

    ReplyDelete
  2. All types of women services will be available in our Chennai Escorts Services
    Chennai Escorts Services

    ReplyDelete
  3. At our escorts, you don’t need to think much about the money because we offer all our services at an affordable price. You will get high-quality services from our end that will not be found anywhere else.

    Escorts in Bangalore

    Independent Bangalore Escorts

    Escort Bangalore

    Bangalore Escort Agency

    Female Escorts in Bangalore

    Call Girls in Bangalore

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. You won't fail to remember the amazing kind of escort services given consistently. In this way, feel free to fill your heart with joy excessively exceptional with our independent Jaipur Call Girls.

    Every one of them is very respectable, tolerant, and sizzling escorts representing rich flavors and changing over your time a great deal outstanding and entrancing. Indeed unquestionably with hot and attractive companions, your companions will get envious.

    Our hot Jaipur escorts will give you a warm and comfortable inclination. Along these lines, in the event that you are quick to go on a long outing. Quick to add some energy, at that point our hot and zesty escorts are promptly accessible for you in Jaipur Over here we guarantee that your vacation time is made remarkable for the duration of your life. Our hot and sizzling Jaipur Call Girls will change over your vacation time into a remarkable one. The rich and pricey kinds of hot young ladies will keep you energised constantly. Book Jaipur call girl services VIP bast hot college girl

    ReplyDelete