471,092 Members | 936 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

Hiding button whilst printing

Hi

I have a form button with a click event which hides the button, prints the window and then brings the button back again
thus:

function winprint()
{
document.form1.printBtn.style.display="none";
document.form1.backBtn.style.display="none";
window.print();
alert('Printing complete...');
document.form1.printBtn.style.display="block";
document.form1.backBtn.style.display="block";
}

My puzzle is that, if I comment out the alert box line the buttons are printed, whilst with the alert box the print is
as I wish. Why is this - and is there a way of printing without the buttons which doesn't require user input to dismiss
the alert?

Thanks
--
Richard
Feb 16 '07 #1
3 1183
ASM
Richard Walker a écrit :
Hi

I have a form button with a click event which hides the button, prints
the window and then brings the button back again thus:
Can't you use CSS ?

<style type="text/css" media="print">
..prt { display: none; }
</style>

<button class="prt" onclick="window.print()">Print</button>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 16 '07 #2
ASM wrote:
Richard Walker a écrit :
>Hi

I have a form button with a click event which hides the button, prints
the window and then brings the button back again thus:

Can't you use CSS ?

<style type="text/css" media="print">
.prt { display: none; }
</style>

<button class="prt" onclick="window.print()">Print</button>
Indeed you can use CSS - a much nicer way of doing the job,
Thanks
--
Richard
Feb 16 '07 #3
On Fri, 16 Feb 2007 11:13:31 +0000, Richard Walker
<to*****@forNOSPAM.co.ukwrote:
Indeed you can use CSS - a much nicer way of doing the job,
Thanks
button {display: none}

Feb 16 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Rob McLennan - ZETLAND | last post: by
1 post views Thread by Fedor Buyakov | last post: by
3 posts views Thread by Penny Bond | last post: by
22 posts views Thread by Mr Newbie | last post: by
11 posts views Thread by Alex | last post: by
1 post views Thread by Rob Meade | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.