更新时间:2023-12-04 11:44:10
PHP不会将事件发送到浏览器.您可以使用Javascript做到这一点.
PHP doesn't send Events to a Browser. You can do that with Javascript.
<input type="button" onclick="window.print()" value="Print Table" />
要隐藏所有其他不想打印的东西,请将其添加到html中:
To hide all the other Stuff you don't want to print add this to your html:
<style media="printer">
.noprint * {
display:none;
}
然后将css类noprint分配给您不想打印的父元素.
And assign the css class noprint to the parent element you don't want to get printed.
未经测试,但这也可以工作:
Not tested but this could work too:
body {
visibility: hidden;
}
.printthis {
visibility: visible;
}
并为您的表提供类printthis,这样就只会打印该表.
And give your table the class printthis and so only the table gets printed.