Programming > JavaScript

protect site from printing

(1/3) > >>

chloe vevrier:
How can I prevent a certain item from print.

greatlog:
You can handle this by using CSS. Put following code inside the <HEAD> tag.

--- Code: ---<style type="text/css" media="print">
  body{ display: none;}
</style>

--- End code ---

chloe vevrier:
No. Its not working. I am getting blank page. I want to print some part of page. Like I have invoice report on a page and at the bottom their is 'Print' button. When customer clicks on it printing dialog appears. On the printed page word print is also at the bottom of invoice. I just want to remove 'print button' from printed page

Reema Khan:
Use noprint css option for print button. Look at the example code.

<head>
<style type="text/css">
@media print{
.noprint { display:none }
}
</style>
</head>
<body>
<table class="noprint" width="100%">
  <tr>
    <td> This Table will not print. Put your Print button in this table</td>
  </tr>
</table>
<table width="100%">
  <tr>
    <td> This Table will print. Put Report here or anywhere you like</td>
  </tr>
</table>
</body>

I hope this will work

missile:
Thanks Reema. You are great. I was looking for this from a long time...

Navigation

[0] Message Index

[#] Next page

Go to full version