美文网首页
html打印

html打印

作者: RemenberMe | 来源:发表于2023-05-18 15:19 被阅读0次

    const onPrint = () => {
        let printNode:any = document.getElementById('previewEditorContentTextBox');

        let iframe:any = document.createElement('iframe');
        iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
        document.body.appendChild(iframe);

        iframe.contentDocument.write(printNode.innerHTML);
        iframe.contentDocument.close();
        iframe.contentWindow.print();

        document.body.removeChild(iframe);
    }


相关文章

网友评论

      本文标题:html打印

      本文链接:https://www.haomeiwen.com/subject/kvowsdtx.html