就像竹林的灯火,被风吹过,摇摇曳曳,但永不熄灭!

利用 iframe 标签打印元素

<img src="cfg-resource/coral40/views/component/quickmarkprint/quickmark.jpg" id="printImg" width="100%" heigth="100%"/>
复制代码
    var printImg=document.getElementById("printImg");
    var iframe = document.createElement('iframe');
    iframe.setAttribute('style', 'display:none');
    document.body.appendChild(iframe);
    var doc = iframe.contentWindow.document;
    doc.write(printImg.outerHTML);
    doc.close()
    iframe.contentWindow.focus();
    iframe.contentWindow.print();
    iframe.remove();
复制代码

 

posted @   竹林的灯火  阅读(355)  评论(0编辑  收藏  举报
努力加载评论中...

w3school 在线教程 | 博客园 | sxsoft | 快包网 | 荆门泽优软件有限公司博客

点击右上角即可分享
微信分享提示