2012-10-14 18 views
12

निम्न कोड अच्छी तरह से काम करता है और स्क्रीन पर एक फेसबुक पॉपअप लॉन्च करता है, हालांकि यह पॉपअप केंद्रित नहीं है।स्क्रीन के केंद्र में फेसबुक शेयर पॉपअप लॉन्च करें

<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 स्क्रिप्ट अपडेट कर लें कर सकते हैं इतना है कि यह 2 स्क्रिप्ट के साथ संयोजन में काम करता है परिणाम के लिए:

<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;} 

<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> 

यहाँ स्क्रिप्ट कि एक पॉपअप विंडो केन्द्रों है स्क्रीन के केंद्र में लॉन्च होने वाली पॉपअप विंडो में। (क्योंकि कोडिंग के साथ मेरा अनुभव बहुत सीमित है, मुझे नहीं पता कि यह कैसे करना है।) धन्यवाद ढेर। पिया

उत्तर

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

बदल सकते हैं जो बिल्कुल पूरी तरह से काम करता है! आप एक सुपर प्रतिभा कोडर परम uber ठंडा व्यक्ति हैं। धन्यवाद। :) पिया @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> 

आप छवि को बदल सकते हैं की कोशिश करो या शब्द
आकार पॉप-अप डब्ल्यू इंडो
width=626,height=436
आप आकार

संबंधित मुद्दे