一、效果展示
二、代码实现:
1.微博分享
< a title= "分享到新浪微博" id= "wb" class= "bshare-sinaminiblog" > < / a>
< script>
var currUrl = window. location. href
$( '#wb' ) . click ( function ( ) {
window. open ( 'http://service.weibo.com/share/share.php?url=' + currUrl + '&title=' + '{$data[' title']}' + '&pics=' + '{$data[' image']}' ) ;
} )
< / script>
2.QQ好友分享
< a title= "分享到QQ好友" id= "hy" class= "bshare-qqim" onclick= "qq();" > < / a>
< script>
function qq ( title, url, pic)
{
var p = {
url: window. location. href,
desc: '' ,
title : '{$data[' title']}' ,
summary : '' ,
pics : '{$data[' image']}' ,
flash : '' ,
site: 'QQ分享'
} ;
var s = [ ] ;
for ( var i in p) {
s. push ( i + '=' + encodeURIComponent ( p[ i] || '' ) ) ;
}
var target_url = "http://connect.qq.com/widget/shareqq/iframe_index.html?" + s. join ( '&' ) ;
window. open ( target_url, 'qq' , 'height=520, width=720' ) ;
}
< / script>
3.QQ空间分享
<! DOCTYPE HTML >
< html>
< head>
< title> QQ空间分享</ title>
< meta http-equiv = " Content-Type" content = " text/html; charset=utf-8" />
</ head>
< body>
< input type = " button" onclick = " shareQQzone();" value = " 分享" > </ input>
</ body>
< script src = " http://qzonestyle.gtimg.cn/qzone/app/qzlike/qzopensl.js#jsdate=20111201" charset = " utf-8" > </ script>
< script>
function shareQQzone ( ) {
var _url = 'www.wodexiangce.cn' ;
var _showcount = '0'
var _desc = '我正在我的相册网冲洗照片' ;
var _summary = '大家都来看看吧' ;
var _title = '真不错' ;
var _site = '我的相册网' ;
var _pic = '' ;
var _width= '800px' ;
var _height= '500px' ;
var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?' ;
_shareUrl += 'url=' + encodeURIComponent ( _url|| document. location) ;
_shareUrl += '&showcount=' + _showcount|| 0 ;
_shareUrl += '&desc=' + encodeURIComponent ( _desc|| '分享的描述' ) ;
_shareUrl += '&summary=' + encodeURIComponent ( _summary|| '分享摘要' ) ;
_shareUrl += '&title=' + encodeURIComponent ( _title|| document. title) ;
_shareUrl += '&site=' + encodeURIComponent ( _site|| '' ) ;
_shareUrl += '&pics=' + encodeURIComponent ( _pic|| '' ) ;
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' ) ;
}
</ script>
</ html>
全部代码:
< div class = " focus_details_title" > {$data['title']}</ div>
< div class = " bshare-custom" >
< span> 分享:</ span>
< a title = " 分享到新浪微博" id = " wb" class = " bshare-sinaminiblog" > </ a>
< a title = " 分享到QQ空间" id = " kj" class = " bshare-qzone" onclick = " shareQQzone();" > </ a>
< a title = " 分享到QQ好友" id = " hy" class = " bshare-qqim" onclick = " qq();" > </ a>
</ div>
< script src = " http://qzonestyle.gtimg.cn/qzone/app/qzlike/qzopensl.js#jsdate=20111201" charset = " utf-8" > </ script>
< script>
function shareQQzone ( ) {
var _url = window. location. href;
var _showcount = '0'
var _desc = '' ;
var _summary = '' ;
var _title = '{$data[' title']}' ;
var _site = '' ;
var _pic = '{$data[' image']}' ;
var _width= '800px' ;
var _height= '500px' ;
var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?' ;
_shareUrl += 'url=' + encodeURIComponent ( _url|| document. location) ;
_shareUrl += '&showcount=' + _showcount|| 0 ;
_shareUrl += '&desc=' + encodeURIComponent ( _desc|| '分享的描述' ) ;
_shareUrl += '&summary=' + encodeURIComponent ( _summary|| '分享摘要' ) ;
_shareUrl += '&title=' + encodeURIComponent ( _title|| document. title) ;
_shareUrl += '&site=' + encodeURIComponent ( _site|| '' ) ;
_shareUrl += '&pics=' + encodeURIComponent ( _pic|| '' ) ;
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' ) ;
}
function qq ( title, url, pic )
{
var p = {
url: window. location. href,
desc: '' ,
title : '{$data[' title']}' ,
summary : '' ,
pics : '{$data[' image']}' ,
flash : '' ,
site: 'QQ分享'
} ;
var s = [ ] ;
for ( var i in p) {
s. push ( i + '=' + encodeURIComponent ( p[ i] || '' ) ) ;
}
var target_url = "http://connect.qq.com/widget/shareqq/iframe_index.html?" + s. join ( '&' ) ;
window. open ( target_url, 'qq' ,
'height=520, width=720' ) ;
}
var currUrl = window. location. href
$ ( '#wb' ) . click ( function ( ) {
window. open ( 'http://service.weibo.com/share/share.php?url=' + currUrl + '&title=' + '{$data[' title']}' + '&pics=' + '{$data[' image']}' ) ;
} )
</ script>
完成~