废话不多说,直接上代码
HTML
<div class="viewshare wb"></div>
JS
$('.wb').click(function(){
window.sharetitle = title; //分享内容的标题
window.shareUrl = encodeURIComponent(location.href);//分享内容的链接,链接一定要用encodeURIComponent处理一下,不然分享之后的链接会没有参数
window.shareImg = imgUrl; //分享内容的图片链接
wbshare();
});
function wbshare(){
var d= window;
d.location.href="http://service.weibo.com/share/share.php?url="+d.shareUrl+"&title="+d.sharetitle+"&searchPic=true";//微博自动抓取图片用这个
d.location.href="http://service.weibo.com/share/share.php?url="+d.sha