By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,821 Members | 1,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,821 IT Pros & Developers. It's quick & easy.

Hiding button whilst printing

P: n/a
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
Share this Question
Share on Google+
3 Replies

P: n/a
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

P: n/a
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

P: n/a
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.