Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created March 1, 2012 11:54
Show Gist options
  • Save Takazudo/1949302 to your computer and use it in GitHub Desktop.
Save Takazudo/1949302 to your computer and use it in GitHub Desktop.
put google plus button dynamically
var gplusoneLoaded = false;
// gplus
var $gplus = $('#somewhere'); // the src is like <div id="somewhere"><!-- put plus button here! --></div>
if($gplus.size()){
window.___gcfg = {lang: 'ja'};
$gplus.html('<div class="g-plusone" data-size="medium" data-href="' + window.location.href + '"></div>');
if(!gplusoneLoaded){
gplusoneLoaded = true;
$.getScript("https://apis.google.com/js/plusone.js");
}else{
if(gapi){ // IE7 can't handle it
gapi.plusone.go();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment