1、首先要在页面写出点击可进行微博分享的入口,样式因自己项目而定:
<li class=\"bottomIcon_5 shareSina\"><a href=\"javascript:;\" rel=\"external nofollow\" target=\"_blank\"></a><div class=\"shareTxt\">微博</div></li>
2、其次,对微博按钮进行点击事件,也就是最重要的进行微博分享的操作:
// 微博分享 $(\'.shareSina\').on(\'click\', function () { window.sharetitle = $(\".print-tit\").html();//分享的标题 window.shareUrl = $(\".myShare img\").attr(\'src\');//分享显示的图片 share(); }) function share() { (function(s, d, e) { try {} catch (e) {} var f = \'http://v.t.sina.com.cn/share/share.php?\', u = window.location.href, p = [\'url=\', e(u), \'&title=分享的名称\', \'&pic=\', e(window.shareUrl)].join(\'\'); function a() { if (!window.open([f, p].join(\'\'), \'mb\', [\'toolbar=0,status=0,resizable=1,width=620,height=450,left=\', (s.width - 620) / 2, \',top=\', (s.height - 450) / 2].join(\'\'))) u.href = [f, p].join(\'\'); }; if (/Firefox/.test(navigator.userAgent)) { setTimeout(a, 0) } else { a() } })(screen, document, encodeURIComponent); }
点击后会出现一个新弹窗的页面,页面内含有你要分享的图片及网站的名称、详情等,页面会跳转到新浪微博,如果你已经登录微博,那么会直接分享成功,如果没有登陆,会跳转到登录页面,登陆后直接分享成功。
3、这样微博就分享成功了!
以上就是本次介绍的全部知识点内容,感谢大家的学习和对的支持。
© 版权声明
THE END
暂无评论内容