File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Printer friendly page with javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Printer friendly page with javascript" Watch "Printer friendly page with javascript" New topic

Printer friendly page with javascript

raghavendra pola

Joined: Jan 18, 2007
Posts: 11
Hi guys ,
I have following page to display the printer friendly page of a current page using javascript

the following is the javascript

The problem is that after displaying the printer frriendly page , the focus is shifting back to main window from print friendly window.

So when window.print happens , it is printing the main window instead of printing the printer friendly window.

Can somebody please help me with this .

perfection is making best effort within constraints of space ,time and resources
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61606

Put the print operation in the sub-page.

P.S. There are better ways to create printer-friendly pages. Look up CSS print media.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376

should be

You really do not need to use JavaScript, you can learn about CSS Print Media

I agree. Here's the link:
subject: Printer friendly page with javascript