PDA

View Full Version : Is it possible to open a new window and Print


newkid
05-06-2004, 11:54 PM
I have 2 pages set up one for display and one for printing.
On the display page (partial code below) I have a button to open the printable page called (prt_cal.htm). Is there any way to have the printable page automaticaly print, right now the printable page opens and the user can right click on the page and select the print option, but I would like to have it just automaticaly print.

Such as:
onclick (window.open
what ever code to print)
or when the printable page opens
onload (what ever code print)


<HTML>
<HEAD>
<Title>Monthly Calendar</title>
<SCRIPT language="vbscript">
<!--
Sub MyPrint_onclick
window.open "prt_cal.htm","newwindow","height=500,width=500,top=50,left=50"
End Sub
-->
</SCRIPT>
</HEAD>

<BODY topmargin="0" leftmargin="0">

<td width="100%" align="center" valign="middle" height="1" colspan="6">
<img src="PrintButton.gif" width="95" height="20" Id="MyPrint">
</td>




I hope this makes sense.

Thanks
J.C.

glenngv
05-07-2004, 04:06 AM
Put this in prt_cal.htm:

<body onload="window.print()">

newkid
05-07-2004, 03:51 PM
Glenngv you are the man :thumbsup:

just the code I needed. and I search the books for at-least an hour on this one.

Thanks again, gosh I'm going to owe you a case of the finest at this rate. you keep coming up with solutions and answers to my questions.


Thanks
J.C.

Roy Sinclair
05-07-2004, 06:21 PM
As an aside you should consider using CSS with media specific style sheets so you can have just one page which looks one way onscreen but prints only the parts that need printing.

newkid
05-10-2004, 05:39 PM
Thanks Roy CSS is next item in the learning bin. Didn't realize you could use CSS like that any suggestions on sources for CSS (books, sites, etc) training, I'll need something real basic, since my HTML knowledge is still being developed.


Thanks
J.C.

Roy Sinclair
05-10-2004, 06:25 PM
This forum is a resource and much of what you asked is answered more simply by pointing you to the HTML and CSS forum sticky thread: http://www.codingforums.com/showthread.php?t=20862

The list of resources there is large enough that you should be able to find a site that suits your style of learning. I would in fact recommend that you go a short way into several of them just to find one that suits you best.