使用JavaScript在IE11中打印iframe

时间:2017-05-23 01:44:07

标签: javascript iframe printing internet-explorer-11

我可以打印iframe但所有文字看起来都是白色的, 这是pdf的屏幕截图:http://i.imgur.com/CQ4CWRi.png
这是我用来打印的代码,我得到的是复选框

        printBTN.addEventListener('click',function(){
            var frame=make('iframe'),
                style=make('style'),
                title=make('title'),
                frameHead;
            style.type='text/css';
            style.innerHTML=
                '.tip{display:none;}'+
                'ol{display:block!important;}'+
                'input[type="button"]{background:none;border:none;padding:0;font-size:inherit;font-style:inherit;}';
            frame.domain=document.domain;
            frame.style.position="fixed";
            frame.style.bottom="0";
            frame.style.right="0";
            frame.style.border="none";
            document.body.appendChild(frame);

            frameHead=frame.contentDocument.getElementsByTagName('head')[0];
            frameHead.appendChild(style);
            title.textContent=document.store.store.value+" Store Manifest";
            frameHead.appendChild(title);
            frame.contentDocument.body.appendChild(document.store.nextElementSibling.cloneNode(true));
            /*frame.contentDocument.write(
                style.outerHTML+
                document.store.nextElementSibling.innerHTML
            );
            frame.contentDocument.close();*/
            frame.focus();
            if(!frame.contentWindow.document.execCommand('print', false, null))
                frame.contentWindow.print();
            document.body.removeChild(frame);
        },false);

0 个答案:

没有答案