Connecting Tech Pros Worldwide Help | Site Map

problem with the printing of alternative pages

meenakshia's Avatar
Member
 
Join Date: Jun 2008
Location: delhi,india
Posts: 33
#1: Aug 16 '08
hi forum
i m trying to print two different pages as soon as the form is saved.

i tried to use this command
<A HREF="javascript:window.print()">Print 1st Page</A>
<A HREF="javascript:window.print()">Print 2nd Page</A>

but i was unable to use the link command to force the printer to print the two other pages

print 1st page should print cust1.htm
and print 2nd page should print cust2.htm

any ideas how to go ahead for the same?
smile always
anand
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Aug 17 '08

re: problem with the printing of alternative pages


window.print() prints the current page. Which page is this code in?
meenakshia's Avatar
Member
 
Join Date: Jun 2008
Location: delhi,india
Posts: 33
#3: Aug 24 '08

re: problem with the printing of alternative pages


hi
thanks for ur reply
well yes i have used the window.print() but it prints a current page
what i want is that if i have page 1.html open
in this page i have 2 links
1st link when clicked will print 2.html page
and 2nd link when clicked will print 3.html page
can you suggest me a way to do so?
i came across an idea that maybe i open both the pages as popup and in those pages use onload to print
is this the right way?
thanks
anand
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Aug 25 '08

re: problem with the printing of alternative pages


Yes, that could work but then you'd have a window open that will need to be closed by the user. An alternative is to use print stylesheets to print only what is required - a kind of "Print-friendly page" using CSS. The way this could work is if you load the stylesheet for the corresponding linked page when the link is clicked.
meenakshia's Avatar
Member
 
Join Date: Jun 2008
Location: delhi,india
Posts: 33
#5: Sep 2 '08

re: problem with the printing of alternative pages


hi thanks for reply
i cud not understand what u meant to say.
can u suggest me with some example
thanks
anand
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Sep 3 '08

re: problem with the printing of alternative pages


It was a suggestion, but it may not work depending on the files to be printed and could actually be quite complex. You load a print stylesheet initially for link 1. This could be achieved by having the linked page loaded in the main page but hidden and the print stylesheet shows it and hides the rest of the content. If link 2 is clicked, it changes the stylesheet to the link 2 stylesheet (which shows the link 2 content and hides the rest) and then prints with window.print().

See Going to Print and Working with Alternate Stylesheets.

As I said, this could be more complex than what you're looking for, so an easy solution would be what you suggested earlier about opening a new window and printing.
Reply