반응형
var SOCIAL_SHARE = { kakaostory: { url: "https://story.kakao.com/share", width: 640, height: 600, makeShareUrl: function(url) { return this.url + "?url="+encodeURIComponent(url); } }, facebook: { url: "https://www.facebook.com/sharer/sharer.php", width: 640, height: 400, makeShareUrl: function(url) { return this.url + "?display=popup&u=" + encodeURIComponent(url) +"&t=" + encodeURIComponent("내용"); } }, twitter: { url: "http://twitter.com", width: 640, height: 400, makeShareUrl: function(url) { return this.url + "?status="+encodeURIComponent("content_example ")+" "+encodeURIComponent(url); } }, naver: { url: "http://share.naver.com/web/shareView.nhn", width: 640, height: 600, makeShareUrl: function(url) { return this.url + "?url="+encodeURIComponent(url) +"&title="+ encodeURIComponent("내용"); } } }; var onClick = function(e) { e.preventDefault(); var $this = $(this), service = SOCIAL_SHARE[$this.data("service")], url = "공유할 링크"; if (service) { e.preventDefault(); window.open(service.makeShareUrl(url), "", "width=" + service.width + ", height=" + service.height); } }; $(".sns_box").off("click", "a").on("click", "a", onClick);
반응형
'프로그래밍 > JavaScipt' 카테고리의 다른 글
javascript 카카오톡 api 메시지보내기 (0) | 2016.07.19 |
---|---|
javascript 카카오스토리 api 링크공유 (0) | 2016.07.19 |
javascript youtube data search api v3 리스트검색 (1) | 2016.06.02 |
javascript prototype 이해 (0) | 2016.06.01 |
javascript youtube api 및 자동재생 (0) | 2016.06.01 |