SOURCE

console 命令行工具 X clear

                    
>
console
function print(){
   var qrcode = new QRCode("qrcode", {
    text: "午夜惊魂",
    width: 256,
    height: 256
});
console.log(document.getElementById("qrcode"));
setTimeout(printView,1);
}

function printView(){
    var el = document.getElementById('qrcode');
            var iframe = document.createElement('IFRAME');
            var doc = null;
            iframe.setAttribute('style',             
            'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
            document.body.appendChild(iframe);
            doc = iframe.contentWindow.document;
            doc.write('' + el.innerHTML + '');
            doc.close();
            var img = $(doc).find("img");
            for(var i = 0; i < img.length; i++) {
                img.eq(i).css("margin", "0 auto");
            }
            iframe.contentWindow.focus();
            iframe.contentWindow.print();
            if(navigator.userAgent.indexOf("MSIE") > 0) {
                document.body.removeChild(iframe);
            }
}
<div id="qrcode" style="display:none"></div>
<input type="button" value="test" onclick="print()"/>

本项目引用的自定义外部资源