페이스북

SNS(페이스북/트위터/핀터레스트) 링크단순공유하기

p-a-r-k 2014. 11. 20. 11:53
반응형

단순히 버튼이나 a태그에 사용할수있는 공유 스크립트

function fnShareFb(sMsg,sUrl) {
	var href = "http://www.facebook.com/sharer.php?u=" + sUrl + "&t=" + encodeURIComponent(sMsg);
	var a = window.open(href, 'facebook', 'width=800, height=500');
	if ( a ) {
	a.focus();
	}
}

function fnShareTw(sUrl){
	var sTxt = "텍스트";

	var href = "http://twitter.com?status="+encodeURIComponent(sTxt)+" "+encodeURIComponent(sUrl);
	var a = window.open(href, 'twitter', 'width=800, height=500');
	if ( a ) {
	a.focus();
	}
}

function fnSharePin(sUrl){
	var sImg = "이미지경로";
	var sTxt = "텍스트";

	var href = "http://www.pinterest.com/pin/create/button/?url="+encodeURIComponent(sUrl)+"&media="+encodeURIComponent(sImg)+"&description="+encodeURIComponent(sTxt);
	var a = window.open(href, 'pinterest', 'width=800, height=500');
	if ( a ) {
	a.focus();
	}
}

반응형