Search code examples
jqueryfacebookhrefgoogle-plus-one

Changing the href on gplus & facebook buttons using javascript


My website is [link-removed] and when you change the page from the main menu it uses ajax to load the main content div, this means the social buttons on the right are still pointing to the original page you landed on, how can I update them along with the page content?

I have tried

$('.sidebar g\\:like').attr("href", x);
$('.sidebar fb\\:like').attr("href", x);

But doesn't seem to work

Any ideas? I am surprised I couldn't find a somebody with a similar problem...


Solution

  • Both of those buttons are iFrames, so you wont be able to do that unless you use the facebook JS API for facebook. I dont think g+ has a non-iframe solution..

    You would need to swap the entire button out with something like:

    $('#social').html('<iframes to facebook and g+ buttons />');