js分享到微信朋友圈、QQ空间、QQ好友、新浪微博、腾讯微博、豆瓣、人人......

各种分享......

<!DOCTYPE html>
<html>
<head>
<title>share</title>
<script src="https://www.oyhdo.com/static/home/js/jquery-2.0.0.min.js"></script>
</head>
<body>
<div class="shareList">
    <ul class="clearfix">
        <a href="javascript:;" οnclick="share_wx();">微信朋友圈</a>
        <a href="javascript:;" οnclick="share_qq();">QQ好友</a>
        <a href="javascript:;" οnclick="share_kj();">QQ空间</a>
        <a href="javascript:;" οnclick="share_wb();">新浪微博</a>
        <a href="javascript:;" οnclick="share_qqwb();">腾讯微博</a>
        <a href="javascript:;" οnclick="share_db();">豆瓣网</a>
        <a href="javascript:;" οnclick="share_renren();">人人网</a>
    </ul>
</div>
<div class="shareClose"><a href="javascript:share();"></a></div>

<!-- 微信分享 start-->
<div class="bdsharebuttonbox" style="display:none;"><xx style="float: left; font-size: 12px;line-height:30px;"> </xx><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信" id="wx_share"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdUrl":"https://blog.csdn.net/msllws","bdPic":"","bdStyle":"1","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<!-- 微信分享 end-->

</body>
</html>
<script type="text/javascript">
//分享到微信朋友圈
function share_wx(){
    var el = document.getElementById('wx_share');
    el.target = '_new';
    el.click();
}

//分享到QQ好友
function share_qq(){
    event.preventDefault();
    var _shareUrl = 'https://connect.qq.com/widget/shareqq/iframe_index.html?';
        _shareUrl += 'url=' + encodeURIComponent(location.href);   //分享的链接
        _shareUrl += '&title=' + encodeURIComponent(document.title);     //分享的标题
    window.open(_shareUrl,'_blank');
}

//分享到QQ空间
function share_kj(){
    var p = {  
        url:location.href,  
        showcount:'1',/*是否显示分享总数,显示:'1',不显示:'0' */  
        desc:'李维山',/*默认分享理由(可选)*/  
        summary:'李维山',/*分享摘要(可选)*/  
        title:'李维山',/*分享标题(可选)*/  
        site:'李维山',/*分享来源 如:腾讯网(可选)*/  
        // pics:'', /*分享图片的路径(可选)*/ 
        style:'203',  
        width:98,  
        height:22  
    };  
    var s = [];  
    for(var i in p){  
        s.push(i + '=' + encodeURIComponent(p[i]||''));  
    }  
    window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?"+s.join('&'));  
}

//分享到新浪微博
function share_wb() { 
    var txtVal = '李维山';         
    var url = window.location.href;
    window.open("http://v.t.sina.com.cn/share/share.php?appkey=4120396272&title=" + encodeURIComponent(txtVal)+"&url="+encodeURIComponent(url));
}

//分享到腾讯微博
function share_qqwb() { 
	var content = "李维山";
	var url = location.href;
	var picurl = "";
    var shareqqstring='http://v.t.qq.com/share/share.php?title='+content+'&url='+url+'&pic='+picurl;
 	window.open(shareqqstring,'newwindow','height=500,width=1000,top=200,left=500');
}

//分享到豆瓣
function share_db(){
    var title = '李维山';
    var _shareUrl = 'http://shuo.douban.com/!service/share?';
        _shareUrl += 'href=' + encodeURIComponent(location.href);    //分享的链接
        _shareUrl += '&name=' + encodeURIComponent(title);    //分享的标题
        _shareUrl += '&image=' + encodeURIComponent('');    //分享的图片
        window.open(_shareUrl,'_blank');
}

//分享到人人网
function share_renren(){
    var title = '李维山';
    var _shareUrl = 'http://share.renren.com/share/buttonshare.do?'; 
    _shareUrl += 'link=' + encodeURIComponent(location.href); //分享的链接 
    _shareUrl += '&title=' + encodeURIComponent(title); //分享的标题 
    window.open(_shareUrl,"'_blank','width='80',height='50'"); 
}
</script>
发布了103 篇原创文章 · 获赞 167 · 访问量 18万+

猜你喜欢

转载自blog.csdn.net/msllws/article/details/84970153