分享到js代码 支持图片分享

本文介绍了一个JavaScript函数,用于将包含标题、图片和内容的信息分享到社交网络。通过此函数,用户可以轻松地在sns平台上分享带有图片的内容。

//title为分享链接的标题,pic为图片,content为内容

function shareToSns(title,pic,content){

document.writeln("<!-- 添加sns -->");
document.write("<a href=\"javascript:(function(){window.open('http://v.t.sina.com.cn/share/share.php?title="+title+"--源自科学视界(http://v.kepu.cn)%20&url='+encodeURIComponent(location.href)+'&pic="+pic+"','_blank','width=600,height=450');})()\" title=\"分享到新浪微博\"><img src='../images/nr_bfy_07.jpg' border='0' alt='新浪微博' title='分享到新浪微博'/></a>");
document.write("&nbsp;<a href=\"javascript:(function(){window.open('http://v.t.qq.com/share/share.php?title="+title+"--源自科学视界(http://v.kepu.cn)%20&url='+encodeURIComponent(location.href)+'&pic="+pic+"','_blank','width=600,height=450');})()\" title=\"分享到QQ微博\"><img src='../images/nr_bfy_09.jpg' border='0' alt='腾讯微博' title='分享到腾讯微博'/></a>");
document.write("&nbsp;<a href=\"javascript:(function(){window.open('http://t.sohu.com/third/post.jsp?title="+title+"--源自科学视界(http://v.kepu.cn)%20&url='+encodeURIComponent(location.href)+'&pic="+pic+"&content=utf-8','_blank','width=600,height=450');})()\" title=\"分享到搜狐微博\"><img src='../images/nr_bfy_11.jpg' border='0' alt='搜狐微博' title='分享到搜狐微博'/></a>");
document.write("&nbsp;<a href=\"javascript:(function(){window.open('http://apps.hi.baidu.com/share/?title="+title+"--源自科学视界(http://v.kepu.cn)%20&url='+encodeURIComponent(location.href),'_blank','width=600,height=450');})()\" title=\"分享到百度空间\"><img src='http://www.baidu.com//favicon.ico' border='0' alt='百度空间' title='分享到百度空间'/></a>");
document.write("&nbsp;<a href=\"javascript:(function(){window.open('http://www.kaixin001.com/rest/records.php?url='+encodeURIComponent(location.href)+'&pic="+pic+"&content="+title+"--源自科学视界(http://v.kepu.cn)%20"+content+"&starid=0&aid=0&style=11','_blank','width=600,height=450');})()\" title=\"分享到开心网\"><img src='../images/nr_bfy_14.jpg' border='0' alt='开心网' title='分享到开心网'/></a>");
document.write("&nbsp;<a href=\"javascript:(function(){window.open('http://share.renren.com/share/buttonshare.do?title="+title+"--源自科学视界(http://v.kepu.cn)%20&link='+encodeURIComponent(location.href)+'&pic="+pic+"','_blank','width=600,height=450');})()\" title=\"分享到人人网\"><img src='../images/nr_bfy_06.jpg' border='0' alt='人人网' title='分享到人人网'/></a>");
document.write("&nbsp;<a href=\"javascript:(function(){window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(location.href)+'&title="+title+"--源自科学视界(http://v.kepu.cn)%20&pics="+pic+"','_blank','width=600,height=450');})()\" title=\"分享到QQ空间\"><img src='../images/nr_bfy_08.jpg' border='0' alt='QQ空间' title='分享到QQ空间'/></a>");
document.writeln("<!-- 添加sns结束 -->");
document.writeln("");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值