Home  >  Article  >  Backend Development  >  javascript - How to use Baidu sharing in the list page?

javascript - How to use Baidu sharing in the list page?

WBOY
WBOYOriginal
2016-09-11 11:34:131083browse

On a list page, I need Baidu Sharing interface to share each piece of information individually. However, the custom interface I use Baidu Sharing is always for sharing web pages. How to do this? javascript - How to use Baidu sharing in the list page?

Reply content:

On a list page, I need Baidu Sharing interface to share each piece of information individually. However, the custom interface I use Baidu Sharing is always for sharing web pages. How to do this? javascript - How to use Baidu sharing in the list page?

I have done this before, but there is no method. I will switch to a third-party one later, and it is also free. This plugin is very powerful.
Please refer to the following for details
http://blog.bshare.cn/

<code>var shareurl = "";
    var sharedesc="";
    var sharepic="";
    var sharetitle="";
    $(".bdsharebuttonbox a").mouseover(function () {
        shareurl = $(this).parents(".bdsharebuttonbox").attr("data-url");
        sharedesc=$(this).parents(".bdsharebuttonbox").attr("data-desc");
        sharepic=$(this).parents(".bdsharebuttonbox").attr("data-pic");
        sharetitle=$(this).parents(".bdsharebuttonbox").attr("data-title");
    });
    function SetShare(cmd, config) {            
            if (shareurl) {
                config.bdUrl = shareurl;                
            }
            if(sharedesc){
                config.bdDesc = sharedesc;    
            }
            if(sharepic){
                config.bdPic = sharepic;    
            }
            if(sharetitle){
               config.bdText = sharetitle;    
            }
            return config;
    }
    window._bd_share_config = {"common": {onBeforeClick:SetShare,"bdSnsKey":{},"bdMini":"2","bdMiniList":false,"bdStyle":"0","bdSize":"24"}, "share": {}}
        with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</code>

Just add the corresponding custom link, title and other information to the bdsharebuttonbox layer

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn