0
Print Button
Participant
,
/t5/coldfusion-discussions/print-button/td-p/938452
Jan 30, 2008
Jan 30, 2008
Copy link to clipboard
Copied
I have the following button on the top of my page, to print :
<td><input type="button" value="Print" onClick="window.print()" /></td>
It works fine, when I click the button, the printer page comes up and I am able to print the page. But I have two issues :
1. The print button prints also, along with the rest of the page. Is there a way to print the page without including the print button ?
2. After the page prints, I want to us cflocation to redirect to another page. How can I do that with the exisitng code ?
thanks
<td><input type="button" value="Print" onClick="window.print()" /></td>
It works fine, when I click the button, the printer page comes up and I am able to print the page. But I have two issues :
1. The print button prints also, along with the rest of the page. Is there a way to print the page without including the print button ?
2. After the page prints, I want to us cflocation to redirect to another page. How can I do that with the exisitng code ?
thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/print-button/m-p/938453#M85944
Jan 30, 2008
Jan 30, 2008
Copy link to clipboard
Copied
trojnfn wrote:
> I have the following button on the top of my page, to print :
>
> <td><input type="button" value="Print" onClick="window.print()" /></td>
>
> It works fine, when I click the button, the printer page comes up and I am
> able to print the page. But I have two issues :
>
> 1. The print button prints also, along with the rest of the page. Is there a
> way to print the page without including the print button ?
Create a css style block with a 'media="print"' and style that button
with a 'display: none'. This will cause it to not be printed.
> 2. After the page prints, I want to us cflocation to redirect to another page.
> How can I do that with the exisitng code ?
You can not use <cflocation...>. This is running on the client in the
browser. The ColdFusion server is done with and forgotten about this
request and moved on to the next one. You need you to use some type of
JavaScript relocation solution such as location.href="someURL.html".
Just place the appropriate relocation logic after the print logic in
your onClick, or better yet inside a combination function that you use
unobtrusive JavaScript techniques to add to this <input...> button.
> I have the following button on the top of my page, to print :
>
> <td><input type="button" value="Print" onClick="window.print()" /></td>
>
> It works fine, when I click the button, the printer page comes up and I am
> able to print the page. But I have two issues :
>
> 1. The print button prints also, along with the rest of the page. Is there a
> way to print the page without including the print button ?
Create a css style block with a 'media="print"' and style that button
with a 'display: none'. This will cause it to not be printed.
> 2. After the page prints, I want to us cflocation to redirect to another page.
> How can I do that with the exisitng code ?
You can not use <cflocation...>. This is running on the client in the
browser. The ColdFusion server is done with and forgotten about this
request and moved on to the next one. You need you to use some type of
JavaScript relocation solution such as location.href="someURL.html".
Just place the appropriate relocation logic after the print logic in
your onClick, or better yet inside a combination function that you use
unobtrusive JavaScript techniques to add to this <input...> button.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
trojnfn
AUTHOR
Participant
,
/t5/coldfusion-discussions/print-button/m-p/938454#M85945
Jan 30, 2008
Jan 30, 2008
Copy link to clipboard
Copied
I already have the following style sheet. Will the one with
media=print override this one :
<style type="text/css">
body {background: white; color: black; text-align: justify;
font-family: arial, helvetica, arial, sans-serif; font-size: 10pt; }
h1 {font-size: 80pt; }
h2 {font-size: 12pt; }
p {text-align: justify;}
th {font-family: arial, helvetica, arial, sans-serif; font-size: 10pt; }
td {font-family: arial, helvetica, arial, sans-serif; font-size: 10pt; }
</style>
<style type="text/css">
body {background: white; color: black; text-align: justify;
font-family: arial, helvetica, arial, sans-serif; font-size: 10pt; }
h1 {font-size: 80pt; }
h2 {font-size: 12pt; }
p {text-align: justify;}
th {font-family: arial, helvetica, arial, sans-serif; font-size: 10pt; }
td {font-family: arial, helvetica, arial, sans-serif; font-size: 10pt; }
</style>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/print-button/m-p/938455#M85946
Jan 30, 2008
Jan 30, 2008
Copy link to clipboard
Copied
trojnfn wrote:
> I already have the following style sheet. Will the one with media=print
> override this one :
>
> <style type="text/css">
>
Since this one has no 'media' parameter it defaults to 'all' and will
apply to both screen and print. Thus elements will only be overridden
if you explicitly override them in the print style.
Just add something along this line:
<style type="text/css" media="print">
input#printBtn{ display: none;}
</style>
Of course you will need to give the button an id parameter of
'printBtn'. Then the button will not be printed.
You can build this up to quite sophisticated levels. I once had an
application that was a large calender display that with extensive use of
media="all", media="screen" and media="print" showed a vertical layout
optimized to and 800 pixel wide screen and a landscape printout
optimized to an 11in x 17in page.
> I already have the following style sheet. Will the one with media=print
> override this one :
>
> <style type="text/css">
>
Since this one has no 'media' parameter it defaults to 'all' and will
apply to both screen and print. Thus elements will only be overridden
if you explicitly override them in the print style.
Just add something along this line:
<style type="text/css" media="print">
input#printBtn{ display: none;}
</style>
Of course you will need to give the button an id parameter of
'printBtn'. Then the button will not be printed.
You can build this up to quite sophisticated levels. I once had an
application that was a large calender display that with extensive use of
media="all", media="screen" and media="print" showed a vertical layout
optimized to and 800 pixel wide screen and a landscape printout
optimized to an 11in x 17in page.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
trojnfn
AUTHOR
Participant
,
/t5/coldfusion-discussions/print-button/m-p/938456#M85947
Jan 30, 2008
Jan 30, 2008
Copy link to clipboard
Copied
Hello Ian,
I got the print button part (do not display) to work.
Now I want to redirect the page after printing, and I have this, but it does nothing. What am I missing ?
<input type="button" value=" Print" id="print_button" onClick="window.print()" location.href="view_urdn.cfm&urdn_number=#form.urdn_number#" />
thanks
I got the print button part (do not display) to work.
Now I want to redirect the page after printing, and I have this, but it does nothing. What am I missing ?
<input type="button" value=" Print" id="print_button" onClick="window.print()" location.href="view_urdn.cfm&urdn_number=#form.urdn_number#" />
thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/coldfusion-discussions/print-button/m-p/938457#M85948
Jan 30, 2008
Jan 30, 2008
Copy link to clipboard
Copied
trojnfn wrote:
> Hello Ian,
>
> I got the print button part (do not display) to work.
>
> Now I want to redirect the page after printing, and I have this, but it does
> nothing. What am I missing ?
>
> <input type="button" value=" Print" id="print_button" onClick="window.print()"
> location.href="view_urdn.cfm&urdn_number=#form.urdn_number#" />
>
> thanks
>
"location.href" is JavaScript. It needs to be inside the onClick
parameter. No guarantees I have the syntax just right. A quick syntax
lookup is strongly advised.
<input type="button" value=" Print" id="print_button"
onClick="window.print();location.href='view_urdn.cfm&urdn_number=#form.urdn_number#'"
/>
> Hello Ian,
>
> I got the print button part (do not display) to work.
>
> Now I want to redirect the page after printing, and I have this, but it does
> nothing. What am I missing ?
>
> <input type="button" value=" Print" id="print_button" onClick="window.print()"
> location.href="view_urdn.cfm&urdn_number=#form.urdn_number#" />
>
> thanks
>
"location.href" is JavaScript. It needs to be inside the onClick
parameter. No guarantees I have the syntax just right. A quick syntax
lookup is strongly advised.
<input type="button" value=" Print" id="print_button"
onClick="window.print();location.href='view_urdn.cfm&urdn_number=#form.urdn_number#'"
/>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

