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

标签 javascript php html 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  - "; 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> 

关于javascript - PHP/CSS/JS - 在保留文档标题的同时禁用打印按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22413842/

相关文章:

javascript - 关闭 popify 模式并保持页面中的滚动位置

php - TCPDF序列化TCPPDFtag参数

php - 将 CodeIgniter 文件从 WAMP 迁移到 LAMP 的正确方法是什么?

javascript - 样式表后,对 Javascript 的 div 调用停止工作

javascript - 无法将选中设置为默认 - knockout 复选框

javascript - 如果 hasClass 条件 jquery 无法正常工作

javascript - 如何从 lodash 导入和使用 _.sortBy

javascript - typescript kendo-ui 从字符串调用方法

php - 如何通过记住 token 禁用用户登录?

php - 2011 : DIVs OR TABLEs? Div/Input/Labels 是否仍然可行,还是 XHTML Tables (tables/tr/td) 重新流行?