468,535 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,535 developers. It's quick & easy.

I need some help please


I have a html page that I don't want anyone to print. Is there a way using
JavaScript to send an alert to the user to warn [or stop] them from trying
to print the html page? Is there an onPrint event handler? In my book
'JavaScript a Beginner's Guide' by John Pollock none is listed. Can a
function be written that will execute if someone tries to print the html?
Thanks in advance

P.S. I also have a printable version of the page in pdf which is for
printing
Jul 23 '05 #1
3 2698
Ivo
"Russell McDade" <do******************@all.com> typed
I have a html page that I don't want anyone to print. Is there a way using
JavaScript to send an alert to the user to warn [or stop] them from trying
to print the html page? Is there an onPrint event handler?
There isn't, and if there were, I could use the "Print-Screen" button,
modify the script on the page via the addressbar, turn off Javascript
altogether, etc.etc. The idea is on a par with disabling right-clicks to
"protect" images, it goes against the nature of the web. And for anything
like a solution, knowing why you do not want it in the first place might
help.
P.S. I also have a printable version of the page in pdf which is for
printing


That is certainly nice. If you put the following on your page, who would
want to disturb your peace:
<p>Please do not this page. I also have a <a
href="printableversion.pdf">printable version</a> of the page in pdf which
is for printing.</p>

By the way, we all want help. Descriptive subject lines do just that.
HTH
Ivo
Jul 23 '05 #2
On Sun, 23 May 2004 10:09:27 +1000, in comp.lang.javascript "Russell
McDade" <do******************@all.com> wrote:
|
| I have a html page that I don't want anyone to print. Is there a way using
| JavaScript to send an alert to the user to warn [or stop] them from trying
| to print the html page? Is there an onPrint event handler? In my book
| 'JavaScript a Beginner's Guide' by John Pollock none is listed. Can a
| function be written that will execute if someone tries to print the html?
| Thanks in advance
|
| P.S. I also have a printable version of the page in pdf which is for
| printing
|

<head>
<link rel=alternate media=print href="mypage.pdf">

</head>

or

<style>
@media print {
..noPrint { display: none; }
}
</style>
<body>
<div class="noPrint">
....
</div>
---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #3

"Jeff North" <jn****@yourpantsbigpond.net.au> wrote in message
news:bv********************************@4ax.com...

<snip previous>
<head>
<link rel=alternate media=print href="mypage.pdf">

</head>

or

<style>
@media print {
.noPrint { display: none; }
}
</style>
<body>
<div class="noPrint">
...
</div>
---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply


Thanks Jeff, both these techniques work.

Russell

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by mike | last post: by
5 posts views Thread by John Flynn | last post: by
5 posts views Thread by TrvlOrm | last post: by
7 posts views Thread by Timothy Shih | last post: by
8 posts views Thread by skumar434 | last post: by
reply views Thread by U S Contractors Offering Service A Non-profit | last post: by
21 posts views Thread by asif929 | last post: by
5 posts views Thread by Justin | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.