bShare分享插件|自定义分享按钮|异步加载分享解决办法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>bshare简单调用Js Api demo</title>
<link rel="Shortcut Icon" href="http://www.bshare.cn/favicon.ico" type="image/x-icon"/>
<link href="http://www.mtou091.com/ceshi/jstest/debug.css" rel="stylesheet" />
<head>
<style>
ul li { float:left; list-style-type:none; color: #999999; margin-right:0px; height:16px; line-height:16px; font-size:12px; margin-left:5px; }
.bshare img { border:none; }
</style>

<!--bshare 分享按钮主功能js -->
<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js"></script>
<script type="text/javascript" charset="utf-8" >
//预定义bshare分享按钮样式及配置参数
var bShareOpt = {style:-1,uuid:'',mdiv:-1};

function shareTo(event, shortName,obj) {
   //自定义设置内容,可动态获取当前页面内相应的参数进行传递
   var url= obj.url || "http://www.bshare.cn/";
   var str_title = obj.tit || "testTitle";
   var str_info = obj.info || "testSummary";
   var img = obj.img || "http://static.bshare.cn/images/bshare-logo-main.gif";
   //清除自定义分享内容的方法,在设置前清空,重新自定义内容
   bShare.entries = [];
   //添加自定义分享内容方法,不需要自定义的可以传递,bshare js会主动抓取页面相应值默认
   bShare.addEntry({
     title: str_title,
     url: url,
     summary: str_info,
       pic:img
  });
  //调用相应的分享方法,
  bShare.share(event, shortName);
}
</script>

<body>
<div class="wrap">
<div style="padding:200px 200px;margin:100px 100px;">
    <ul class="bshare">
        <li>分享到:</li>
        <li>
            <a title="分享到一键通"  onclick="shareTo(this,'bsharesync',{'url':'http://weather.com.cn','tit':'你是我的小','info':'这里好似摘要','img':'http://i.weather.com.cn/i/product/pic/l/sevp_nmc_weap_sob_efg_achn_lno_p9_20150113050002400.jpg'})" href="javascript:void(0);" ><img src="http://static.bshare.cn/frame/images/logos/s4/bsharesync.gif "/></a>
        </li>
        <li>
            <a title="分享到新浪微博"  onclick="shareTo(this,'sinaminiblog',{'url':'http://weather.com.cn','tit':'你是我的小','info':'这里好似摘要','img':'http://i.weather.com.cn/i/product/pic/l/sevp_nmc_weap_sob_efg_achn_lno_p9_20150113050002400.jpg'})" href="javascript:void(0);" ><img src="http://static.bshare.cn/frame/images/logos/s4/sinaminiblog.gif "/></a>
        </li>
        <li>
            <a title="分享到QQ空间"  onclick="shareTo(this,'qzone',{'url':'http://weather.com.cn','tit':'你是我的小','info':'这里好似摘要','img':'http://i.weather.com.cn/i/product/pic/l/sevp_nmc_weap_sob_efg_achn_lno_p9_20150113050002400.jpg'})" href="javascript:void(0);" ><img src="http://static.bshare.cn/frame/images/logos/s4/qzone.gif "/></a>
        </li>
        <li>
            <a title="分享到人人网"  onclick="shareTo(this,'renren',{'url':'http://weather.com.cn','tit':'你是我的小','info':'这里好似摘要','img':'http://i.weather.com.cn/i/product/pic/l/sevp_nmc_weap_sob_efg_achn_lno_p9_20150113050002400.jpg'})" href="javascript:void(0);" ><img src="http://static.bshare.cn/frame/images/logos/s4/renren.gif "/></a>
        </li>
        <li>
            <a title="分享到豆瓣"  onclick="shareTo(this,'douban',{'url':'http://weather.com.cn','tit':'你是我的小','info':'这里好似摘要','img':'http://i.weather.com.cn/i/product/pic/l/sevp_nmc_weap_sob_efg_achn_lno_p9_20150113050002400.jpg'})" href="javascript:void(0);" ><img src="http://static.bshare.cn/frame/images/logos/s4/douban.gif "/></a>
        </li>
    </ul>
</div>
</body>
</html>
原文地址:https://www.cnblogs.com/liujinyu/p/4221465.html