html5 页面分享功能(微信、新浪微博、QQ)

 <div class="new_sharebtnbox" data-tag="share">
     <a class="new_box new_wechat" data-cmd="wechat"></a>
     <a class="new_box new_weibo " data-cmd="weibo"></a>
     <a class="new_box new_qq" data-cmd="qzone"></a>
 </div>
 <script src="https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
 <script>
     var fg = true; //防止微信二维码重复生成的bug
     var path = window.document.location.href;
     var tle = $('.new_title').text();
     //var path = "https://baidu.com";
     var ShareTip = function() {};
     //1、微信
     $('.new_wechat').click(function () {
          $('.new_qrcode').fadeIn(500);
          if(fg){
             $("#qrcode").qrcode({
                text: path,       //设置二维码内容
                pic: "https://baidu.com/xxx1.png",
                render: "table", //设置渲染方式
                width: 200,       //设置宽度,默认生成的二维码大小是 256×256
                height: 200,      //设置高度
                margin: "auto",
                typeNumber: -1,   //计算模式
                background: "#fff", //背景颜色
                foreground: "#000" //前景颜色
              });
            }
            fg = false;
       });
       $('.new_close').click(function () {
           $('.new_qrcode').fadeOut(500);
       });
      //2、新浪微博
       ShareTip.prototype.sina = function(title, url, picurl) {
            var sharesinastring = 'http://v.t.sina.com.cn/share/share.php?title=' + title + '&url=' + url + '&content=utf-8&sourceUrl=' + url + '&pic=' + picurl;
            window.open(sharesinastring, 'newwindow', 'height=300,width=300,top=100,left=100');
       };
       $('.new_weibo').click(function () {
           let sh1 = new ShareTip();
           sh1.sina(tle, window.location.href, "https://baidu.com/xxx1.png");
       });
      //3、QQZone
      ShareTip.prototype.qqzone = function(title, url, picurl) {
          var shareqqzonestring = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title=' + title + '&url=' + url + '&pics=' + picurl;
          window.open(shareqqzonestring, 'newwindow', 'height=300,width=300,top=100,left=100');
      };
      $('.new_qq').click(function () {
           let sh2 = new ShareTip();
           sh2.qqzone(tle, window.location.href, "https://baidu.com/xxx1.png");
      });
  </script>

参考:https://www.cnblogs.com/shuangjiang/p/9524588.html

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

逸曦穆泽

您的鼓励是我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值