본문 바로가기

Web/JAVASCRIPT

소셜보내기

반응형
function openNewsWin(openUrl) {
	var winObj;
	winObj = window.open(openUrl,"sendNewsWin","width=1024, height=800");
}

function openNewsWin2(openUrl) {
	var winObj;
	winObj = window.open(openUrl,"sendNewsWin","width=700, height=600, scrollbars=yes, resizable=yes, menubar=yes, toolbar=yes, statusbar=yes");
}

function openNewsWin3(openUrl) {
	var winObj;
	winObj = window.open(openUrl,"sendNewsWin","width=466, height=356");
}

function sendNews(media,locTitle,locUrl) {
//openNewsWin,openNewsWin2,openNewsWin3는 각자 알맞게 수정하시면됩니다.
	if(locUrl == undefined){
		locUrl = window.location.href;
	}
	if(locTitle == undefined){
		locTitle = encodeURI(document.title);
	}else{
		locTitle = encodeURI(locTitle);
	}
	locTag = encodeURI("태그명");

	switch(media) {
		case "twitter":
			sendUrl = "http://twitter.com/home?status="+ locTitle +"+"+encodeURI(locUrl);
			openNewsWin(sendUrl);
			break;
		case "metoday":
			sendUrl = "http://me2day.net/posts/new?new_post[body]=\""+ locTitle +"\":"+encodeURI(locUrl)+"&new_post[tags]="+locTag;
			openNewsWin(sendUrl);
			break;
		case "naver":
			sendUrl = "http://bookmark.naver.com/post?ns=1&title="+ locTitle +"&url="+encodeURI(locUrl);
			openNewsWin(sendUrl);
			break;
		case "google":
			sendUrl = "http://www.google.com/bookmarks/mark?op=add&title=\""+ locTitle +"\"&bkmk="+encodeURI(locUrl);
			openNewsWin(sendUrl);
			break;
		case "cyworld":
			sendUrl = "http://csp.cyworld.com/bi/bi_recommend_pop.php?url="+ locUrl +"&title="+locTitle+"&thumbnail=&summary=&writer=";
			openNewsWin2(sendUrl);
			break;
		case "facebook":
			sendUrl = "http://www.facebook.com/sharer.php?u="+encodeURI(locUrl)+"&data_title="+ locTitle +"";
			openNewsWin2(sendUrl);
			break;
		case "yozm":
			sendUrl = "http://yozm.daum.net/api/popup/prePost?prefix="+encodeURI(locTitle)+"&link="+ encodeURI(locUrl) +"";
			openNewsWin3(sendUrl);
			break;
	}
}
반응형