faqts : Computers : Programming : Languages : PHP : Common Problems : Security

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 12 people (75%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Is it possible to prevent the results from a query that are displayed on a web page from being printed out on hard copies via the web browser?

Apr 20th, 2008 19:11
jean korte, Ben Udall, Wesley Penner,


You could make it more difficult to print by using CSS and giving the
output a style that has display: none or visibility: none for print
media.  The information would appear normally in the browser but would
not appear in printed output.
Say your results are displayed in a table. You could create a style
either in the head of your document between style tags
<style type="text/css">
@media print {
.noprint{
	display: none;
  }
}
</style>
or as an entry in a CSS file that you link to your page.  Then to use
this style for your table output you would:
<table class="noprint">
. . . 
</table>
A persistent, knowledgeable user could still print the information
either by disabling style sheets in the browser or by copying and
editing the page source.  However, simply clicking print would not
print the page.
----------------------------------------------------------------------
No, anything displayed in a web browser can be printed.