Facebook, Twitter, Metoday 연동

2014. 3. 11. 09:44JavaScript

<%@page language="java" contentType="text/html; charset=EUC-KR"%>
<script type="text/javascript" charset="euc-kr" src="http://bit.ly/javascript-api.js?version=latest&login=ynaa&apiKey=R_d5025d2679f33a31a79d63ad6c97164e"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript">
function go_facebook(s, u) {

var str = document.getElementById("title").value;
var enstr = "[title]=" + encodeURIComponent(str);
var url = "[url]=" + encodeURIComponent(document.URL);
var strpath = "http://www.facebook.com/sharer.php?s=100&p" + url + "&p" + enstr;

//var strpath = "http://www.facebook.com/sharer.php?u="+url+"&t="+enstr;
window.open(strpath, 'Facebook', 'width=680, height=524 ,scrollbars=no, resizable=no');
}

function go_twitter() {
var str = document.getElementById("title").value;
var enstr = encodeURIComponent(str);
var tmphref = document.getElementById("tb").href;
if (document.getElementById("tb").href.indexOf("?text") == -1) {
document.getElementById("tb").href = tmphref + "?text="+enstr;
}else{
document.getElementById("tb").href = tmphref.substring(0, tmphref.indexOf("?text")) + "?text=" + enstr;
}
return true;
}


function go_me2day() {
var strTitle;
strTitle = document.getElementById("title").value;

strTitle = strTitle.replace(/\"/g,'\\\"'); // " --> \" 로 대체
var enstr = encodeURIComponent(strTitle);
var naverAddr = 'http://me2day.net/posts/new';
var strAddr = naverAddr + '?new_post[body]="' + enstr + '":'+ encodeURIComponent(document.URL) + '&new_post[tags]=' + encodeURIComponent('KISDI');
window.open(strAddr);
}
</script>

<ul class="btn_ico">
<li><a href="http://twitter.com/share" onclick="return go_twitter();" id="tb" class="twitter-share-button1" data-count="none" target="_blank"><img src="/images/kr/information/ico_twt.gif" alt="트위터"/></a></li>
<li><img src="/images/kr/information/ico_fab.gif" alt="페이스북" onclick="go_facebook();" style="cursor:pointer"/></li>
<li class="end"><img src="/images/kr/information/ico_m2d.gif" alt="미투데이" onclick="go_me2day();" style="cursor:pointer"/></li>
</ul>

'JavaScript' 카테고리의 다른 글

[Javascript] var, let 그리고 const의 차이  (0) 2017.11.21
배경화면을 이용한 슬라이드  (2) 2015.10.23
Datepicker 시간 선택 Plugin  (0) 2015.05.18
jQuery Radio 버튼처리  (0) 2014.03.11
jQuery SelectBox 사용  (0) 2014.03.11