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>

 


免責聲明!

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



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