Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Print question

Status
Not open for further replies.

robburne

Programmer
May 10, 2005
33
GB
Hi,

I am using a simple piece of javascript code in the body tag of a html document so that when the page is called a print dialogue box pops up automatically:

<body ONLOAD="window.print()";>

Does anyone know if it is possible to make the print pages default to another quantity rather than 1, say for example 4?

Many thanks in advance!

Rob.
 
Nope. Printing is part of the interface that is, rightly so, firmly in the control of the user. All JavaScript can do is bring up the print dialog. In fact, in my opinion, it violates "user interface standards" to even bring up the dialog automatically.

I know, I know - you have some unique special circumstance, such as an internal website where everyone who hits a certain page is TRYING to print.

If that's the case, then I suggest you serve up a PDF instead. PDFs can contain JavaScript code that acts on the Acrobat/PDF DOM, and can silently print on load. That's what I did for a client who worked in a tax office. They wanted to fill out a form, and automatically print the result when the form was submitted and processed.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Hi,

Thanks for the reply, not a problem not being able to do as I wish. In my case the user is clicking a button that says 'PRINT' so I don't think I am violating anyones user interface, just making the system I am developing more user friendly.

Many thanks,

Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top