Created
March 1, 2012 11:54
-
-
Save Takazudo/1949302 to your computer and use it in GitHub Desktop.
put google plus button dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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