網頁分享到facebook


一、在網頁頭部加入如下代碼:

    <meta property="og:url" class="fb_url" content="分享url" />
    <meta property="og:type"               content="website" />
    <meta property="og:title" class="fb_title" content="標題" />
    <meta property="og:description"        content="內容" />
    <meta property="og:image" content="圖片"/>

以上屬性值根據自身網站修改

二、HTML代碼如下:

<a href="javascript:fbShare();" class="xq-facebook"><i class="share-icon-facebook"></i> <span>facebook</span></a>

三、JavaScript代碼如下:

function fbShare(contentId) {

        u = document.getElementsByClassName("fb_url")[0].content;

        t = document.getElementsByClassName("fb_title")[0].content;

        window.open("http://www.facebook.com/sharer.php?u="+ encodeURIComponent(u) + "&t="+ encodeURIComponent(t), "sharer","toolbar=0,status=0,width=626,height=436");
        

    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM