2012-10-14 4 views
12

다음 코드는 잘 작동하고 화면에 페이스 북 팝업을 시작하지만이 팝업은 중앙에 있지 않습니다. 그 결과 2 스크립트와 함께 작동하도록화면 센터에서 페이스 북 공유 팝업 시작

<script type="text/javascript"> 
function MyPopUpWin(url, width, height) { 
    var leftPosition, topPosition; 
    //Allow for borders. 
    leftPosition = (window.screen.width/2) - ((width/2) + 10); 
    //Allow for title and status bars. 
    topPosition = (window.screen.height/2) - ((height/2) + 50); 
    //Open the window. 
    window.open(url, "Window2", 
    "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" 
    + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" 
    + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"); 
} 
</script> 

사람이 1 스크립트를 업데이트하십시오 수 : 여기

<a href="http://www.facebook.com/share.php?u=<full page url to share" onClick="return fbs_click()" target="_blank" title="Share This on Facebook"><img src="images/facebookimage.jpg" alt="facebook share"></a> 

<script type="text/javascript"> 
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;} 
는 팝업 창을 중심 스크립트입니다 화면 중앙에 팝업 창이 나타납니다. (코딩에 대한 나의 경험이 매우 제한적이므로이 작업을 수행하는 방법을 알지 못합니다.) 감사합니다. 피아

답변

32

참조이 당신을 위해 작동하는 경우 :

<script type="text/javascript"> 
function fbs_click(width, height) { 
    var leftPosition, topPosition; 
    //Allow for borders. 
    leftPosition = (window.screen.width/2) - ((width/2) + 10); 
    //Allow for title and status bars. 
    topPosition = (window.screen.height/2) - ((height/2) + 50); 
    var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"; 
    u=location.href; 
    t=document.title; 
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures); 
    return false; 
} 
</script> 

<!-- Please change the width and height to suit your needs --> 
<a href="http://www.facebook.com/share.php?u=<full page url to share" onClick="return fbs_click(400, 300)" target="_blank" title="Share This on Facebook"><img src="images/facebookimage.jpg" alt="facebook share"></a> 
+9

그건 절대적으로 완벽하게 작동합니다! 당신은 슈퍼 천재 코더 최고의 냉정한 사람이야. 감사. :) 피아 @arturhoo – user1736794

+0

그것이 당신을 위해 일한 것을 알면 다행! – arturhoo

+0

정확히 내가 찾고 있던 것도 - 정말 고마워요! – Ingusmat

0



    <script type="text/javascript"> 
    function fbs_click() { 
     u=location.href;t=document.title;window.open(
     'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t), 
     'sharer','toolbar=0,status=0,width=626,height=436');return false; 
     } 
    </script> 

    <a href="http://www.facebook.com/share.php?u=<url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a> 


또는 이미지를 변경할 수 있습니다



    <script type="text/javascript"> 
    function fbs_click() { 
     u=location.href;t=document.title;window.open(
     'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t), 
     'sharer','toolbar=0,status=0,width=626,height=436');return false; 
     } 
    </script> 

    <a href="http://www.facebook.com/share.php?u=<url>" onclick="return fbs_click()" target="_blank"><img src="http://originus.samsung.com/us/images/support/facebook-share.png"/></a> 

페이스 북

에 사진과 함께이 기사를보십시오 또는 단어
크기 팝업 w indow
width=626,height=436
크기를 변경할 수 있습니다.