您的位置:首页 > Web前端 > JavaScript

JavaScript分享新浪微博、QQ空间、腾讯微博

2016-06-04 17:42 816 查看

一、先看效果图:

如图:是分享新浪微博的页面。



二、分享新浪微博、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、腾讯微博

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息