Created
August 1, 2012 19:24
-
-
Save ryu-blacknd/3229930 to your computer and use it in GitHub Desktop.
非同期でソーシャルボタンの.jsを読み込むサンプル
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
<script type="text/javascript"> | |
( function( doc, script ) { | |
var js; | |
var fjs = doc.getElementsByTagName( script )[0]; | |
var add = function( url, id, o ) { | |
if ( doc.getElementById( id ) ) { return; } | |
js = doc.createElement( script ); | |
js.src = url; js.async = true; js.id = id; | |
fjs.parentNode.insertBefore( js, fjs ); | |
if ( window.ActiveXObject && o != null ) { | |
js.onreadystatechange = function() { | |
if ( js.readyState == 'complete' ) o(); | |
if ( js.readyState == 'loaded' ) o(); | |
}; | |
} else { | |
js.onload = o; | |
} | |
}; | |
// Google+1 | |
window.___gcfg = { lang: "ja" }; | |
add( '<a href="https://apis.google.com/js/plusone.js" target="_blank" rel="noreferrer" style="cursor:help;display:inline !important;">https://apis.google.com/js/plusone.js</a>' ); | |
add( '//connect.facebook.net/ja_JP/all.js', 'facebook-jssdk', function() { | |
add( '<a href="http://static.ak.fbcdn.net/connect.php/js/FB.Share" target="_blank" rel="noreferrer" style="cursor:help;display:inline !important;">http://static.ak.fbcdn.net/connect.php/js/FB.Share</a>', 'facebook-share' ); | |
}); | |
add( '//platform.twitter.com/widgets.js', 'twitter-wjs' ); | |
// はてな | |
add( '<a href="http://b.st-hatena.com/js/bookmark_button.js" target="_blank" rel="noreferrer" style="cursor:help;display:inline !important;">http://b.st-hatena.com/js/bookmark_button.js</a>', 'hatena-js' ); | |
}( document, 'script' ) ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment