一、先看效果圖:
如圖:是分享新浪微博的頁面。
二、分享新浪微博、QQ空間、騰訊微博的JavaScript代碼
<script type="text/javascript">
function sharexinlang(title,url,picurl){
var sharesinastring='http://v.t.sina.com.cn/share/share.php?title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url+'&pic='+picurl;
window.open(sharesinastring,'newwindow','height=100,width=100,top=100,left=100');
}
function shareqqkongjian(title,url,picurl){
var shareqqzonestring='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary='+title+'&url='+url+'&pics='+picurl;
window.open(shareqqzonestring,'newwindow','height=400,width=400,top=100,left=100');
}
function weixinShareTimeline(content,link,imgUrl){
var shareqqstring='http://v.t.qq.com/share/share.php?title='+content+'&url='+link+'&pic='+imgUrl;
window.open(shareqqstring,'newwindow','height=100,width=100,top=100,left=100');
}
</script>
三、調用方式
<div>
<div style="display: inline-block;float: right;margin-right: 35px;">
<a href="javascript:sharexinlang('${video.introduce}','<%=baseURL %>/playVideo.do?videoId=${video.videoId }','<%=baseURL %>/file/${video.imgPath }')"><img src="<%=baseURL %>/images/xinlang.png"/></a>
</div>
<div style="display: inline-block;float: right;">
<a href="javascript:shareqqkongjian('${video.introduce}','<%=baseURL %>/playVideo.do?videoId=${video.videoId }','<%=baseURL %>/file/${video.imgPath }')"><img src="<%=baseURL %>/images/kongjian.png"/></a>
</div>
<div style="display: inline-block;float: right;">
<a href="javascript:weixinShareTimeline('${video.introduce}','<%=baseURL %>/playVideo.do?videoId=${video.videoId }','<%=baseURL %>/file/${video.imgPath }')">
<img src="<%=baseURL %>/images/weibo.png"></img>
</a>
</div>
<div style="display: inline-block;float: right;">
<font class="title clearfix yh f16">分享本視頻: </font>
</div>
<div style="display: inline-block;float: right;">
<font class="title clearfix yh f16">
<a href="<%=baseURL%>/web/add_discuss.jsp?videoId=${video.videoId}&videoName=${video.videoName }"> 我要評論 </a>
</font>
</div>
</div>
四、調用完成,點擊對應的分享跳出分享頁面。
1、新浪微博
2、QQ空間
3、騰訊微博