PHP/CSS/JS -禁用打印按钮,同时保留文档标题


PHP/CSS/JS - Disable print button while keeping document title

我试图禁用页面上的打印按钮,同时保持文档标题,我在让它工作有一些问题。要么是禁用按钮,没有文档标题要么是文档标题,看看按钮。我有一个或另一个,但不是两个。

这是我的示例代码,有人能看到我做错了什么?我被难住了,已经找了大约一天了,现在试图使它工作。

当然还有更多的页面,但这是与按钮相关的代码。如果您需要更多的页面,请告诉我。

如果有人能看出我在哪里做错了,我想要一个正确方向的指针。

<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>&nbsp;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>&nbsp;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>