facebook Sharer popup window

前端 未结 1 369
梦毁少年i
梦毁少年i 2020-12-12 22:45

The FB sharer popup window displays the data of the page, not the metadata I have inserted in the php link.



        
相关标签:
1条回答
  • 2020-12-12 23:41

    If you want to add custom metadata, use following code:

    <a id="fb-share" style='text-decoration:none;' type="icon_link" onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]=YOUR_DESCRIPTION&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE','sharer','toolbar=0,status=0,width=580,height=325');" href="javascript: void(0)">Share</a>
    

    UPDATE:

    I wrote a little JS code for Facebook Share.

    • JS Code: https://gist.github.com/Stichoza/4942775
    • Live Demo: http://jsfiddle.net/stichoza/EYxTJ/

    Javascript:

    function fbShare(url, title, descr, image, winWidth, winHeight) {
            var winTop = (screen.height / 2) - (winHeight / 2);
            var winLeft = (screen.width / 2) - (winWidth / 2);
            window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width='+winWidth+',height='+winHeight);
        }
    

    HTML:

    <a href="javascript:fbShare('http://jsfiddle.net/stichoza/EYxTJ/', 'Fb Share', 'Facebook share popup', 'http://goo.gl/dS52U', 520, 350)">Share</a>
    
    0 讨论(0)
提交回复
热议问题