Programming > JavaScript

protect site from printing

(1/3) > >>

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

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

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

--- 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.

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

I hope this will work

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


[0] Message Index

[#] Next page

Go to full version