Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Print Button

Participant ,
Jan 30, 2008 Jan 30, 2008
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
519
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2008 Jan 30, 2008
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.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 30, 2008 Jan 30, 2008
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>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2008 Jan 30, 2008
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.



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 30, 2008 Jan 30, 2008
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2008 Jan 30, 2008
LATEST
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#'"
/>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources