Last active
December 17, 2015 07:58
-
-
Save kawanet/5576681 to your computer and use it in GitHub Desktop.
Twitter ツイートボタン、Facebook いいねボタン、Google +1 ボタン、LinkedIn ボタンを非同期に表示するための HTML・JavaScript コード
This file contains 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
<!-- JavaScript SDK の非同期読み込み。Facebook のみ App Id が必要 --> | |
<script src="http://platform.twitter.com/widgets.js" async></script> | |
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1&appId=123456789012345" async></script> | |
<script src="http://apis.google.com/js/plusone.js" async></script> | |
<script src="http://platform.linkedin.com/in.js" async></script> |
This file contains 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
// 非同期に追加した要素に対して、JavaScript で各ソーシャルプラグインを呼び出す | |
// ページ内を全て走査し直す場合 | |
twttr.widgets.load(); | |
FB.XFBML.parse(); | |
gapi.plusone.go(); | |
IN.init(); | |
// ページ内のパーツ単位でレンダリングする場合 | |
$('.social-buttons').each(function(idx, elem){ | |
twttr.widgets.load(elem); | |
FB.XFBML.parse(elem); | |
gapi.plusone.go(elem); | |
IN.parse(elem); // で行けるはずだけど、エラーが出る? | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment