JavaScript实现HTML页面集成QQ空间分享功能

 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4     <title>QQ空间分享</title>
 5     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 6 </head>
 7 <body>
 8     <input type="button" onclick="shareQQzone();" value="分享"></input>
 9 </body>
10 <script src="http://qzonestyle.gtimg.cn/qzone/app/qzlike/qzopensl.js#jsdate=20111201" charset="utf-8"></script>
11 <script>
12     //QQ空间分享方法:这样写可以对分享事件进行绑定
13     function shareQQzone(){
14         var _url = 'www.wodexiangce.cn';
15         var _showcount = '0'
16         var _desc = '我正在我的相册网冲洗照片';
17         var _summary = '大家都来看看吧';
18         var _title = '真不错';
19         var _site = '我的相册网';
20         var _pic = '';
21         var _width= '800px';
22         var _height= '500px';
23         
24         var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';
25         _shareUrl += 'url=' + encodeURIComponent(_url||document.location);   //参数url设置分享的内容链接|默认当前页location
26         _shareUrl += '&showcount=' + _showcount||0;      //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示
27         _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述');    //参数desc设置分享的描述,可选参数
28         _shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要');    //参数summary设置分享摘要,可选参数
29         _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享标题,可选参数
30         _shareUrl += '&site=' + encodeURIComponent(_site||'');   //参数site设置分享来源,可选参数
31         _shareUrl += '&pics=' + encodeURIComponent(_pic||'');   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
32         window.open(_shareUrl,'_blank','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');
33     }
34 </script>
35 </html>
原文地址:https://www.cnblogs.com/wbxk/p/6715026.html