Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Window.print不打印整个页面_Javascript_Printing - Fatal编程技术网

Javascript Window.print不打印整个页面

Javascript Window.print不打印整个页面,javascript,printing,Javascript,Printing,我正在jsp中创建一个包含60列的报告表。我可以通过滚动查看所有列。 现在我想打印这份报告。我用来打印的函数是 function printReport(rpt) { var report = document.getElementById(rpt); var newWindow = "toolbar=no, addressbar=no, directories=no,location=no, status=yes, menubar=no, scrollbars=y

我正在jsp中创建一个包含60列的报告表。我可以通过滚动查看所有列。 现在我想打印这份报告。我用来打印的函数是

function printReport(rpt)
{       
    var report = document.getElementById(rpt);
    var newWindow = "toolbar=no, addressbar=no, directories=no,location=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=5000 , height=500, left=50, top=50";
    var printWindow = window.open('',rpt, newWindow);
    printWindow.document.write('<html><body>');
    printWindow.document.write('<div id="rpt" name="rpt" style="overflow:scroll;" >');
    printWindow.document.write(report.innerHTML);       
    printWindow.document.write('</div>');
    printWindow.document.write('</body></html>');
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();    
}   
函数打印报告(rpt)
{       
var报告=document.getElementById(rpt);
var newWindow=“工具栏=否,地址栏=否,目录=否,位置=否,状态=是,菜单栏=否,滚动栏=是,可调整大小=是,宽度=5000,高度=500,左=50,顶部=50”;
var printWindow=window.open(“”,rpt,newWindow);
printWindow.document.write(“”);
printWindow.document.write(“”);
printWindow.document.write(report.innerHTML);
printWindow.document.write(“”);
printWindow.document.write(“”);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}   
现在的问题是它只打印屏幕上可见的内容,即打印的纸张只有大约10列在屏幕上可见。但我想在下一页中打印其余的列,以便打印整个表。 有什么建议吗?

删除

style=“溢出:滚动;”

甚至就是这个(注意我首先删除了parms中的空格,然后删除了大部分,因为它们是不相关的)

函数打印报告(rpt)
{       
var报告=document.getElementById(rpt);
var parms=“滚动条,可调整大小,宽度=500,高度=500,左侧=50,顶部=50”;
var printWindow=window.open(“”,rpt,parms);
printWindow.document.write(“”);
printWindow.document.write(report.innerHTML);
printWindow.document.write(“”);
printWindow.document.close();
printWindow.close();//也不确定这是否正常。
}  
更新:我强烈建议您发送一份PDF,而不是试图强制浏览器按您想要的方式打印页面

style=“溢出:滚动;”

甚至就是这个(注意我首先删除了parms中的空格,然后删除了大部分,因为它们是不相关的)

函数打印报告(rpt)
{       
var报告=document.getElementById(rpt);
var parms=“滚动条,可调整大小,宽度=500,高度=500,左侧=50,顶部=50”;
var printWindow=window.open(“”,rpt,parms);
printWindow.document.write(“”);
printWindow.document.write(report.innerHTML);
printWindow.document.write(“”);
printWindow.document.close();
printWindow.close();//也不确定这是否正常。
}  

更新:我强烈建议您发送一份PDF,而不是强迫浏览器按您的意愿打印您的页面

谢谢您的回复。但我还是得到了同样的结果。注意:我必须打印的报告表是水平滚动的,不是垂直的。你会如何想象这张照片?我强烈建议你按照你想要的方式创建一个pdf,当用户想要打印时,你可以发送给他,谢谢你的回复。但我还是得到了同样的结果。注意:我必须打印的报告表是水平滚动的,不是垂直的。你会如何想象这张照片?我强烈建议你按照你想要的方式创建一个pdf,当用户想要打印时,你可以发送给他
function printReport(rpt)
{       
    var report = document.getElementById(rpt);
    var parms = "scrollbars,resizable,width=500,height=500,left=50,top=50";
    var printWindow = window.open('',rpt, parms);
    printWindow.document.write('<html><body onload="window.focus();window.print()">');
    printWindow.document.write(report.innerHTML);       
    printWindow.document.write('</body></html>');
    printWindow.document.close();
    printWindow.close(); // not sure this is ok either.   
}