将url动态转换成二维码插件 - 兼容IE8

插件地址  http://static.runoob.com/assets/qrcode/qrcode.min.js ,网页直接打开,然后ctrl+s保存到本地。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <button id="btn">分享</button>
        <div id="qrcode" style="display: none;"></div>
        <script src="jquery.min.js"></script>
        <script src="qrcode.min.js"></script>
        <script>
             var qrcode = new QRCode(document.getElementById("qrcode"), {
                width : 200,
                height : 200
            });
            var urlPath = window.location.href;
            qrcode.makeCode(urlPath);
            $("#btn").mouseover(function(){
                $('#qrcode').show();
            }).mouseout(function(){
                $('#qrcode').hide();
            })
            
        </script>
    </body>
</html>

效果截图:

猜你喜欢

转载自www.cnblogs.com/stella1024/p/9172132.html