On one page, add something like this...

<FORM METHOD="POST" ACTION="print-this-doc.taf" onClick="print1()"
TARGET="print-this-doc">

<INPUT TYPE=SUBMIT VALUE="Print "></FORM>

In the header of that page or as a linked JS script, use this for a pop-up
window...

function print1() {

window.open("","suppliers1","width=1,height=1,resizable=no,toolbar=no,locati
on=no,directories=no,scrollbars=no,top=1,left=2000")

                }


left=2000 will pop the window open off screen. Kind of annoying to have it
pop up on screen.

On the page you want to print, us this in the body tag...

<body onload="window.print();setTimeout('window.close()',500);">

Setting the window close to 500 is important because on on some browsers,
most notably on Safari for the Mac, the print will error if not all the
information is loaded on the print page and that page is trying to close,
thus time out to load the page before closing it.

You could also use something like this...


<body onload="window.print();setTimeout('window.close()',500);"
onunload="opener.location=(another-page-or-confirmation-page.taf?_function=p
rintdone')">

to load a different page like a conformation page in the original location
that had the print button.

Hope this helps.





  _____

From: Anthony Humphreys [mailto:anth...@humphreys.org]
Sent: Monday, February 21, 2011 11:08 PM
To: Witango-Talk@witango.com
Subject: Re: Witango-Talk: Print on javascript


For "security reasons", you cannot take control of my printer, nor change
it's settings (like force duplex, or turn off colour, or print 100 copies)


All you can do is offer the user a convenient link to print with
"window.print()" and let the user decide to press OK, or whatever.

I, for one, would not want to be "surprised" to find that some web page has
randomly taken over my printer. However, there are other products which do
allow more control (and offer usually better quality) for printing. However,
the quantity printed is generally on the "honour" system, and limited by
licence. PDF is one such mechanism, but there are others.

With CSS you do have some control over what does, and does not, get sent to
the printer (or screen). This allows you to, for instance, turn off menus
that aren't part of the main content that a user would want printed; or,as
another example, place a different style of banner ad on the printed page,
as opposed to the version of the same ad which appears on the screen -- this
printed version may even include a coupon or discount for a product or a
store. If available in the browser, CSS may even suggest where the page
break should go. But -- again -- it cannot change the settings of, or even
the number of copies on, the printer.

However, some browsers (and/or some browser plug-ins) do allow users to turn
on/off CSS -- or even use a user-supplied CSS. Developers (like myself)
often use tools like these to help them test their pages for certain things.

Anthony -



On Mon, Feb 21, 2011 at 4:41 PM, MC Tay <sm...@media88.com> wrote:


Hi:

We are looking for an alternative print page javascript that would
print once only and without displaying the print dialog. Any one has
any script that can share please?

We use window.print() currently.

Thanks!

MC



----------------------------------------

To unsubscribe from this list, please send an email to lists...@witango.com
with "unsubscribe witango-talk" in the body.





  _____

To unsubscribe from this list, please send an email to lists...@witango.com
with "unsubscribe witango-talk" in the body.


----------------------------------------

To unsubscribe from this list, please send an email to lists...@witango.com 
with "unsubscribe witango-talk" in the body.

Reply via email to