
1、html代码
01 | < div class = "share-div" > |
02 | < span >分享</ span > |
03 | < a class = "a1" > |
04 | < img src = "images/shejiao_02.png" > |
05 | <!--这个容器用来生成qrcode--> |
06 | < div class = "wxpop" id = "qrcode" ></ div > |
07 | </ a > |
08 | <!--分享到QQ空间--> |
09 | < a href = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary=文章标题&desc=文章描述&pics=图片地址&url=文章地址" >< img src = "images/shejiao_03.png" ></ a > |
10 | <!--分享到新浪微博--> |
11 | < a href = "http://v.t.sina.com.cn/share/share.php?title=文章标题&url=文章地址&pic=图片地址" >< img src = "images/shejiao_01.png" ></ a > |
12 | </ div > |
2、引入qrcode.js
1 | < script type = "text/javascript" src = "./js/qrcode.js" ></ script > |
01 | //分享到微信的二维码 |
02 | var path = window.location.href; |
03 | var qrcodeBox = document.getElementById( "qrcode" ); |
04 | qrcodeBox.innerHTML = '' ; |
05 | var qrcode = new QRCode(qrcodeBox, { |
06 | text: path, |
07 | width: 100, |
08 | height: 100, |
09 | colorDark: "#000000" , |
10 | colorLight: "#ffffff" , |
11 | correctLevel: QRCode.CorrectLevel.L |
12 | }); |