【2011.09.01】如何分享文章到新浪微博和QQ空间?如何设置关注按钮?(采用js代码实现)
1.分享到”新浪微博“
<script type="text/javascript" charset="utf-8"> (function(){ var _w = 72 , _h = 16; var param = { url:location.href, type:'3', count:'1', /**是否显示分享数,1显示(可选)*/ appkey:'', /**您申请的应用appkey,显示分享来源(可选)*/ title:'', /**分享的文字内容(可选,默认为所在页面的title)*/ pic:'', /**分享图片的路径(可选)*/ ralateUid:'', /**关联用户的UID,分享微博会@该用户(可选)*/ rnd:new Date().valueOf() } var temp = []; for( var p in param ){ temp.push(p + '=' + encodeURIComponent( param[p] || '' ) ) } document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/
weiboshare.html?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>') })() </script>
2.分享到QQ空间
<script type="text/javascript">
document.write(['<a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=',
encodeURIComponent(location.href),'&title=',encodeURIComponent(document.title),'" target="_blank"
title="分享到QQ空间"><img src="http://qzonestyle.gtimg.cn/ac/qzone_v5/app/app_share/qz_logo.png"
alt="分享到QQ空间" /><\/a>'].join(''));
</script>
3.设置”关注“按钮(采用DIV)
分别是连接到”新浪微博“,”人民微博“,”腾讯微博“。rel后的网址是可修改的。
<div id="jiathis_style_32x32"> <span class="jiathis_txt">关注我们:</span> <a class="jiathis_follow_tsina" rel="http://weibo.com/tshfwh"></a> <a class="jiathis_follow_tpeople" rel="http://t.people.com.cn/tshfwh"></a> <a class="jiathis_follow_tqq" rel="http://t.qq.com/tshfwh"></a> </div>