我试图在保留文档标题的同时禁用页面上的打印按钮,但在使其正常工作时遇到了一些问题。 它是,禁用按钮,没有文档标题或文档标题,看到按钮。 我有一个或另一个,但没有两个。
这是我的示例代码,有人能看出我做错了什么吗?我很困惑,一直在寻找大约一天的时间,试图让它发挥作用。
页面自然不止于此,但这是与按钮相关的代码。 如果您需要更多页面,请告诉我。
如果有人能看到我在这方面出了什么问题,我会喜欢一个指向正确方向的指针。
<head>
<?php //-----------disabling the header and footer when printing-----------------------// ?>
<style type="text/css" media="print">
@page
{
size: auto;
margin: 2mm;
}
@media print
{
.no-print;
{
display: none !important;
}
}
</style>
<?php //-----------end disabling the header and footer when printing-------------------// ?>
</head>
<body>
<table>
<tr>
<td>
<b> You are viewing the report preview for: </b> <?php echo $yearmonthd; ?>
</td>
<td width="370px"> </td>
<td>
<input type="button" onClick='window.print();document.title ="<?php echo "Report for - "; echo $team1; echo " - "; echo $yearmonthd; ?>";' class="no-print" value="Print/Save this report"/>
</td>
</tr>
</table>
</body>
最佳答案
它是;在导致它仍然显示按钮的 .no-print css 声明之后。
尝试:
<head>
<?php //-----------disabling the header and footer when printing-----------------------// ?>
<style type="text/css" media="print">
@page
{
size: auto;
margin: 2mm;
}
@media print
{
.no-print
{
display: none !important;
}
}
</style>
<?php //-----------end disabling the header and footer when printing-------------------// ?>
</head>
<body>
<table>
<tr>
<td>
<b> You are viewing the report preview for: </b> <?php echo $yearmonthd; ?>
</td>
<td width="370px"> </td>
<td>
<input type="button" onClick="window.print();document.title ='<?php echo "Report for - $team1 - $yearmonthd";?>'" class="no-print" value="Print/Save this report"/>
</td>
</tr>
</table>
</body>
关于javascript - PHP/CSS/JS - 在保留文档标题的同时禁用打印按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22413842/