js分享代码(新浪微博,腾讯微博,QQ空间,QQ好友)

js分享代码(新浪微博,腾讯微博,QQ空间,QQ好友)


代码如下:


  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title>君乐科技js分享代码</title>  
  6. </head>  
  7. <body style="background:#e5e6e6;">  
  8. <section>  
  9.     <div>  
  10.     <div class="share-box">  
  11.         <div>  
  12.             <p>点击下方图标直接分享</p>         
  13.             <ul>  
  14.                 <!-- 新浪微博 -->  
  15.                 <li><a href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=真实的appkey',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg','君乐科技','http://www.junlenet.com','页面编码gb2312|utf-8默认gb2312'));"  class="invite-kinds2">新浪微博</a></li>  
  16.                 <!-- QQ好友 -->  
  17.                 <li><a href="javascript:;"  id="qq_id" target="_blank">QQ好友</a></li>  
  18.                 <!-- QQ空间 -->  
  19.                 <li><a href="javascript:;"  onclick = "qqZone()">QQ空间</a></li>  
  20.                 <!-- 腾讯微博 -->  
  21.                 <li><a href="javascript:;"  onclick = "tencentWeiBo()">腾讯微博</a></li>  
  22.             </ul>  
  23.         </div>  
  24.         <div class="ewm" id="qrcode"></div>  
  25.         <!-- 参考:jquery.qrcode.js -->  
  26.     </div>  
  27.     </div>  
  28. </section>  
  29. <hr>  
  30. <h3>直接使用百度分享</h3>  
  31. <div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a></div>  
  32. <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"32"},"share":{},"image":{"viewList":["weixin","tsina","qzone","tqq"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["weixin","tsina","qzone","tqq"]}};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)];</script>  
  33. <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>  
  34. <script>  
  35.   var url = "http://www.junlenet.com";  
  36.     var desc_ = "君乐科技";        
  37.     function tencentWeiBo(){  
  38.          var _url = "http://www.junlenet.com";     
  39.          var _showcount = 0;  
  40.          var _summary = "";  
  41.          var _title = desc_;  
  42.          var _site = "http://www.junlenet.com";    
  43.          var _width = "600px";  
  44.          var _height = "800px";  
  45.          var _pic = "http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg";  
  46.          var _shareUrl = 'http://share.v.t.qq.com/index.php?c=share&a=index';  
  47.          _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //分享的标题  
  48.          _shareUrl += '&url=' + encodeURIComponent(_url||location.href);    //分享的链接  
  49.          _shareUrl += '&appkey=5bd32d6f1dff4725ba40338b233ff155';    //在腾迅微博平台创建应用获取微博AppKey  
  50.          //_shareUrl += '&site=' + encodeURIComponent(_site||'');   //分享来源  
  51.          _shareUrl += '&pic=' + encodeURIComponent(_pic||'');    //分享的图片,如果是多张图片,则定义var _pic='图片url1|图片url2|图片url3....'  
  52.          window.open(_shareUrl,'width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');  
  53.     }      
  54.     var top = window.screen.height / 2 - 250;    
  55.     var left = window.screen.width / 2 - 300;    
  56.     var height = window.screen.height;  
  57.     var width =  window.screen.width;   
  58.     /*title是标题,rLink链接,summary内容,site分享来源,pic分享图片路径,分享到新浪微博*/    
  59.     function shareTSina() {    
  60.         var title = desc_;  
  61.         var   rLink = "http://www.junlenet.com";  
  62.         var backUrl = "http://wx.hengfu100.com/member/c_friend";  
  63.         var site = desc_;  
  64.         var pic = "http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg";  
  65.         window.open("http://service.weibo.com/share/share.php?pic=" +encodeURIComponent(pic) +"&title=" +     
  66.         encodeURIComponent(title.replace(/ /g, " ").replace(/<br \/>/g, " "))+ "&url=" + encodeURIComponent(rLink),    
  67.         "分享至新浪微博",    
  68.         "height=500,width=600,top=" + top + ",left=" + left + ",toolbar=no,menubar=no,scrollbars=noresizable=no,location=nostatus=no");    
  69.     }    
  70.     
  71.      function qqFriend() {  
  72.             var p = {  
  73.                 url : 'http://www.junlenet.com', /*获取URL,可加上来自分享到QQ标识,方便统计*/  
  74.                 desc:'',  
  75.                 //title : '新玩法,再不来你就out了!', /*分享标题(可选)*/  
  76.                 title:desc_,  
  77.                 summary : '', /*分享摘要(可选)*/  
  78.                 pics : 'http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg', /*分享图片(可选)*/  
  79.                 flash : '', /*视频地址(可选)*/  
  80.                 site : 'http://www.junlenet.com', /*分享来源(可选) 如:QQ分享*/  
  81.                 style : '201',  
  82.                 width : 32,  
  83.                 height : 32  
  84.             };  
  85.             var s = [];  
  86.             for ( var i in p) {  
  87.                 s.push(i + '=' + encodeURIComponent(p[i] || ''));  
  88.             }  
  89.             var url = "http://connect.qq.com/widget/shareqq/index.html?"+s.join('&');  
  90.             return url;  
  91.             //window.location.href = url;  
  92.             //document.write(['<a class="qcShareQQDiv" href="http://connect.qq.com/widget/shareqq/index.html?',s.join('&'), '" >分享给QQ好友</a>' ].join(''));  
  93.         }  
  94.       
  95.     function qqZone(){  
  96.          var _url = "http://www.junlenet.com";     
  97.          var _showcount = 0;  
  98.          var _desc = desc_;  
  99.          var _summary = "";  
  100.          var _title = "君乐科技";  
  101.          var _site = "";  
  102.          var _width = "600px";  
  103.          var _height = "800px";  
  104.          var _summary = "";  
  105.          var _pic = "http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg";  
  106.          var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';  
  107.          _shareUrl += 'url=' + encodeURIComponent(_url||document.location);   //参数url设置分享的内容链接|默认当前页location  
  108.          _shareUrl += '&showcount=' + _showcount||0;      //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示  
  109.          _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述');    //参数desc设置分享的描述,可选参数  
  110.          //_shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要');    //参数summary设置分享摘要,可选参数  
  111.          _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享标题,可选参数  
  112.          //_shareUrl += '&site=' + encodeURIComponent(_site||'');   //参数site设置分享来源,可选参数  
  113.          _shareUrl += '&pics=' + encodeURIComponent(_pic||'');   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数  
  114.         window.open(_shareUrl,'width='+_width+',height='+_height+',top='+(screen.height-_height)/2+',left='+(screen.width-_width)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');   
  115.     }  
  116.       
  117.      $(function(){     
  118.         var url = qqFriend();  
  119.         $("#qq_id").attr("href",url);      
  120.      })  
  121. </script>  
  122. </body>  
  123. </html>  
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>君乐科技js分享代码</title>
</head>
<body style="background:#e5e6e6;">
<section>
    <div>
    <div class="share-box">
        <div>
            <p>点击下方图标直接分享</p>       
            <ul>
                <!-- 新浪微博 -->
                <li><a href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=真实的appkey',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg','君乐科技','http://www.junlenet.com','页面编码gb2312|utf-8默认gb2312'));"  class="invite-kinds2">新浪微博</a></li>
                <!-- QQ好友 -->
                <li><a href="javascript:;"  id="qq_id" target="_blank">QQ好友</a></li>
                <!-- QQ空间 -->
                <li><a href="javascript:;"  onclick = "qqZone()">QQ空间</a></li>
                <!-- 腾讯微博 -->
                <li><a href="javascript:;"  onclick = "tencentWeiBo()">腾讯微博</a></li>
            </ul>
        </div>
        <div class="ewm" id="qrcode"></div>
        <!-- 参考:jquery.qrcode.js -->
    </div>
    </div>
</section>
<hr>
<h3>直接使用百度分享</h3>
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"32"},"share":{},"image":{"viewList":["weixin","tsina","qzone","tqq"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["weixin","tsina","qzone","tqq"]}};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)];</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script>
  var url = "http://www.junlenet.com";
    var desc_ = "君乐科技";      
    function tencentWeiBo(){
         var _url = "http://www.junlenet.com";   
         var _showcount = 0;
         var _summary = "";
         var _title = desc_;
         var _site = "http://www.junlenet.com";  
         var _width = "600px";
         var _height = "800px";
         var _pic = "http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg";
         var _shareUrl = 'http://share.v.t.qq.com/index.php?c=share&a=index';
         _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //分享的标题
         _shareUrl += '&url=' + encodeURIComponent(_url||location.href);    //分享的链接
         _shareUrl += '&appkey=5bd32d6f1dff4725ba40338b233ff155';    //在腾迅微博平台创建应用获取微博AppKey
         //_shareUrl += '&site=' + encodeURIComponent(_site||'');   //分享来源
         _shareUrl += '&pic=' + encodeURIComponent(_pic||'');    //分享的图片,如果是多张图片,则定义var _pic='图片url1|图片url2|图片url3....'
         window.open(_shareUrl,'width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
    }    
    var top = window.screen.height / 2 - 250;  
    var left = window.screen.width / 2 - 300;  
    var height = window.screen.height;
    var width =  window.screen.width; 
    /*title是标题,rLink链接,summary内容,site分享来源,pic分享图片路径,分享到新浪微博*/  
    function shareTSina() {  
        var title = desc_;
        var   rLink = "http://www.junlenet.com";
        var backUrl = "http://wx.hengfu100.com/member/c_friend";
        var site = desc_;
        var pic = "http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg";
        window.open("http://service.weibo.com/share/share.php?pic=" +encodeURIComponent(pic) +"&title=" +   
        encodeURIComponent(title.replace(/ /g, " ").replace(/<br \/>/g, " "))+ "&url=" + encodeURIComponent(rLink),  
        "分享至新浪微博",  
        "height=500,width=600,top=" + top + ",left=" + left + ",toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no");  
    }  
  
     function qqFriend() {
            var p = {
                url : 'http://www.junlenet.com', /*获取URL,可加上来自分享到QQ标识,方便统计*/
                desc:'',
                //title : '新玩法,再不来你就out了!', /*分享标题(可选)*/
                title:desc_,
                summary : '', /*分享摘要(可选)*/
                pics : 'http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg', /*分享图片(可选)*/
                flash : '', /*视频地址(可选)*/
                site : 'http://www.junlenet.com', /*分享来源(可选) 如:QQ分享*/
                style : '201',
                width : 32,
                height : 32
            };
            var s = [];
            for ( var i in p) {
                s.push(i + '=' + encodeURIComponent(p[i] || ''));
            }
            var url = "http://connect.qq.com/widget/shareqq/index.html?"+s.join('&');
            return url;
            //window.location.href = url;
            //document.write(['<a class="qcShareQQDiv" href="http://connect.qq.com/widget/shareqq/index.html?',s.join('&'), '" >分享给QQ好友</a>' ].join(''));
        }
    
    function qqZone(){
         var _url = "http://www.junlenet.com";   
         var _showcount = 0;
         var _desc = desc_;
         var _summary = "";
         var _title = "君乐科技";
         var _site = "";
         var _width = "600px";
         var _height = "800px";
         var _summary = "";
         var _pic = "http://www.junlenet.com/uploads/allimg/150510/1-150510104044.jpg";
         var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';
         _shareUrl += 'url=' + encodeURIComponent(_url||document.location);   //参数url设置分享的内容链接|默认当前页location
         _shareUrl += '&showcount=' + _showcount||0;      //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示
         _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述');    //参数desc设置分享的描述,可选参数
         //_shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要');    //参数summary设置分享摘要,可选参数
         _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享标题,可选参数
         //_shareUrl += '&site=' + encodeURIComponent(_site||'');   //参数site设置分享来源,可选参数
         _shareUrl += '&pics=' + encodeURIComponent(_pic||'');   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
        window.open(_shareUrl,'width='+_width+',height='+_height+',top='+(screen.height-_height)/2+',left='+(screen.width-_width)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); 
    }
    
     $(function(){   
        var url = qqFriend();
        $("#qq_id").attr("href",url);    
     })
</script>
</body>
</html>


新浪微博可以直接使用:

var href = "http://service.weibo.com/share/share.PHP?url=http://www.junlenet.com&title=君乐科技&pic=http://www.junlenet.com/uploads/allimg/150510/1-150510104424.jpg&appkey=&searchPic=false";


运行效果如下:




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值