我想从网页中打印出来。我已经为此和这项工作编写了代码。代码是:
function printPage(){
var tableData = '<table border="1">'+document.getElementsByTagName('table')[0].innerHTML+'</table>';
var data = '<button onclick="window.print()">Print this page</button><br/>'+tableData;
myWindow=window.open('','','width=500,height=600');
myWindow.innerWidth = screen.width;
myWindow.innerHeight = screen.height;
myWindow.screenX = 0;
myWindow.screenY = 0;
myWindow.document.write(data);
myWindow.focus();
};
但我不想在打印输出中显示“打印此页”按钮。
最佳答案
您可以使用@media css样式方法:
@media print {
/* css here to take out the "print this */
}
这只会在您打印时应用 css 样式。
例如,您可以为按钮指定一个类,例如 class="printbtn"
然后:
@media print {
.printbtn { display: none; }
}
关于php - 如何使用php打印网页的某些部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15803461/