网页分享到微信、微博、QQ空间、百度贴吧等
生活随笔
收集整理的這篇文章主要介紹了
网页分享到微信、微博、QQ空间、百度贴吧等
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.首先說明的是,pc端微信分享只能通過二維碼來分享。
2.下面是js代碼。
//分享到新浪微博function shareToSinaWB(event){event.preventDefault();var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136'; //真實的appkey,必選參數_shareUrl += '&url='+ encodeURIComponent(_url||document.location); //參數url設置分享的內容鏈接|默認當前頁location,可選參數_shareUrl += '&title=' + encodeURIComponent(_title||document.title); //參數title設置分享的標題|默認當前頁標題,可選參數_shareUrl += '&source=' + encodeURIComponent(_source||'');_shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||'');_shareUrl += '&content=' + 'utf-8'; //參數content設置頁面編碼gb2312|utf-8,可選參數_shareUrl += '&pic=' + encodeURIComponent(_pic||''); //參數pic設置圖片鏈接|默認為空,可選參數window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0');}//分享到QQ空間function shareToQzone(event){event.preventDefault();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,'_blank','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到百度貼吧function shareToTieba(event){event.preventDefault();var _shareUrl = 'http://tieba.baidu.com/f/commit/share/openShareApi?';_shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的標題_shareUrl += '&url=' + encodeURIComponent(_url||document.location); //分享的鏈接_shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的圖片window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到豆瓣function shareToDouban(event){event.preventDefault();var _shareUrl = 'http://shuo.douban.com/!service/share?';_shareUrl += 'href=' + encodeURIComponent(_url||location.href); //分享的鏈接_shareUrl += '&name=' + encodeURIComponent(_title||document.title); //分享的標題_shareUrl += '&image=' + encodeURIComponent(_pic||''); //分享的圖片window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到騰訊微博function shareToQQwb(event){event.preventDefault();var _shareUrl = 'http://v.t.qq.com/share/share.php?';_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,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到開心網function shareToKaixin(event){event.preventDefault();var _shareUrl = 'http://www.kaixin001.com/rest/records.php?';_shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的鏈接_shareUrl += '&content=' + encodeURIComponent('分享的文字'); //需要分享的文字,當文字為空時,自動抓取分享網址的title_shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的圖片,多個使用半角逗號分隔_shareUrl += '&showcount=0'; //是否顯示分享數,顯示:'1',不顯示:'0'_shareUrl += '&style=11'; //顯示的樣式,必選參數_shareUrl += '&aid=' + encodeURIComponent(_site||''); //顯示分享來源window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}function shareToKaixin2(event){event.preventDefault();var _shareUrl = 'http://www.kaixin001.com/repaste/share.php?';_shareUrl += 'rtitle=' + encodeURIComponent(_title||document.title); //分享的標題window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到facebookfunction shareToFacebook(event){event.preventDefault();var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?';_shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的鏈接_shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的標題window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到facebookfunction shareToFacebook(event){event.preventDefault();var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?';_shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的鏈接_shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的標題window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}//分享到Twitterfunction shareToTwitter(event){event.preventDefault();var _shareUrl = 'http://twitter.com/intent/tweet?';_shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的鏈接_shareUrl += '&text=' + encodeURIComponent(_title||document.title); //分享的標題window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');}
轉載于:https://www.cnblogs.com/WangXinPeng/p/11504326.html
總結
以上是生活随笔為你收集整理的网页分享到微信、微博、QQ空间、百度贴吧等的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 日志处理工具 SeasLog
- 下一篇: 进程比较基础的内容