0

I want to print a div has has the overflow-x:auto; property (it wraps several page widths).

In Chrome, the page is scaled and it displays correct. However, in IE (8-10), it cuts off the div to the part that's visible on screen.

Below is my function:

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;
        }

Is there anything I can add to the function to correctly print my div?

4

1 回答 1

1

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

printWindow.document.write('<style media="print">a_selector_for_the_div{overflow-x:visible;}</style>');
于 2013-08-26T15:20:03.753 回答