Window.Print() Div with Overflow-x?



我想打印一个div,它有overflow-x:auto;属性(它包装了几个页面宽度)。

在Chrome中,页面经过缩放,显示正确。然而,在IE(8-10)中,它将div截断到屏幕上可见的部分。

以下是我的功能:

function print() {
            var printContent = document.getElementById("<%=printable.ClientID%>");
            var windowUrl = 'about:blank';
            var uniqueName = new Date();
            var windowName = 'Print' + uniqueName.getTime();
            var printWindow = window.open(windowUrl, windowName, 'left=5000,top=5000,width=0,height=0');
            printWindow.document.write("<html> ");
            printWindow.document.write("<head> ");
            printWindow.document.write("<link type=text/css rel=stylesheet href='/eBusinessStylesNew.css' /> ");
            printWindow.document.write("</head> ");
            printWindow.document.write("<body topmargin=0 leftmargin=0 bgcolor='#ffffff'> ");
            printWindow.document.write(printContent.innerHTML);
            printWindow.document.write("</body> ");
            printWindow.document.write("</html> ");
            printWindow.document.close();
            printWindow.focus();
            printWindow.print();
            printWindow.close();
            return false;
        }

有什么可以添加到函数中以正确打印div吗?

试试这个(在<link...>之后):

printWindow.document.write('<style media="print">a_selector_for_the_div{overflow-x:visible;}</style>');

最新更新