더 나은 프로그래머가 되자

트위터,페이스북,구글플러스 연동 스크립트 함수 sns 본문

언어/js

트위터,페이스북,구글플러스 연동 스크립트 함수 sns

greathuman 2011. 10. 18. 09:45



<script type="text/javascript">
 function goFaceBook(title,url)
 {
  var href = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(url) + "&t=" + encodeURIComponent(title);
  var a = window.open(href, 'facebook', 'width=600,height=300');
  if (a) {
   a.focus();
  }
 }
 
 function goTwitter(title,url)
 {
  var href = "http://twitter.com/share?text=" + encodeURIComponent(title) +" "+ encodeURIComponent(url);
  var a = window.open(href, 'twitter', 'width=600,height=300');
  if (a) {
   a.focus();
  }
 }

 function goGoogleplus(title,url)
 {
  var href = "https://plus.google.com/share?url=" + encodeURIComponent(url);
  var a = window.open(href, 'google', 'width=600,height=400,scrollbars=yes');
  if (a) {
   a.focus();
  }
 }
 </script>

 

<a onclick="goTwitter();">트위터</a>

Comments