Click to See Complete Forum and Search --> : I need some help with a "print page" script, please.


D.S.R.Clark
06-01-2003, 10:35 PM
To whom it may concern,

I found this neat little script here in the site. But I would like it to do something a little different than it does. Currently it prints the page that it is loaded onto. I would like it to print a page of my chosing. For example: I load one page and it directs it to print another.
Can anyone please help. Here is the script below.
Thank you in advance.
David S. R. Clark






<!-- TWO STEPS TO INSTALL PRINT PAGE (AUTOMATIC):

1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">


<!-- Begin
function printPage() {
if (window.print) {
agree = confirm('This page contains sensitive information that \nwe recommend you print a copy of at this time. \n\nOK to print now?');
if (agree) window.print();
}
}
// End -->
</script>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY OnLoad="printPage()">

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.79 KB -->






<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

Jona
06-01-2003, 11:15 PM
Actually, I'd use a server-side language to send a printing request. However, since you're using JavaScript, you can only print the same page. Or if you open a new window, you can print that window's contents. Otherwise, you can't. You can, in IE, print a seperate text document, but it doesn't work in anything except for IE.

Jona

AdamGundry
06-02-2003, 02:02 AM
I'd use a server-side language to send a printing request.How would you do that? I wasn't aware that any server-side code could instruct the browser to print the current document - is this a special HTTP header or something?

Adam

Jona
06-02-2003, 09:06 AM
Perhaps I have a misunderstanding. I figured the client received the print, not the server. Apparently, it looks like I was wrong. Pardon my ignorance. http://us2.php.net/manual/en/ref.printer.php is what I was thinking...

I apologize,
Jona