それぞれの公式が用意しているシェアボタンではなく、独自の画像やテキストでシェアしたい時にピッタリ。
JSで現在のページのURLを取得し、シェアする仕組みになっています。
※jQueryが入っていないと動かないのでここではソースだけの紹介になります。
ソースはこちら
1 2 3 4 5 6 |
<div><a href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');">フェイスブック</a></div> <div><a href="javascript:window.open('http://twitter.com/share?text='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');">Twitter</a></div> <div><a href="javascript:window.open('http://line.me/R/msg/text/?'+encodeURIComponent(document.title)+'%20'+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');">LINE</a></div> |