spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column91


Print Templates, Part II: TemplatePrinter

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

Code Listing of the Print Template

<HTML XMLNS:IE>
<HEAD>
<?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default">
<STYLE TYPE="text/css">
.contentstyle
{
    width:5.5in;
    height:8in;
    margin:1in;
    background:white;   
    border:1 dashed gray;
}
.masterstyle
{ 
    width:8.5in;
    height:11in;
    background:#FFFF99;   
	border-left:1 solid black;
	border-top:1 solid black;
	border-right:4 solid black;
	border-bottom:4 solid black;
    margin:10px;
}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
invocations = 0;

function CheckIfPrintRequested() {
  invocations++;
  if (invocations > 1) return;
  switch (dialogArguments.__IE_PrintType) {
    case "Prompt":
      if (printer.showPrintDialog()) PrintPrep();
      break;
    case "NoPrompt":
      PrintPrep();
      break;
    case "Preview":
    default:
      break;
  }
}

function PrintPrep() {
  if (layoutrect1.contentDocument.readyState == "complete") {
    PrintNow();
  }
  else {
    layoutrect1.contentDocument.onreadystatechange = PrintWhenContentDocComplete;
  }
}

function PrintWhenContentDocComplete() {
  if (layoutrect1.contentDocument.readyState == "complete")	{
    layoutrect1.contentDocument.onreadystatechange = null;
    PrintNow();
  }
}

function PrintNow() {
  printer.startDoc("Printing from template2.htm");
  printer.printPage(page1);	
  printer.printPage(page2);
  printer.stopDoc();
}
// -->
</SCRIPT>

</HEAD>
<BODY>
<IE:TEMPLATEPRINTER ID="printer"/>

<IE:DEVICERECT ID="page1" CLASS="masterstyle" MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect1" CONTENTSRC="document" CLASS="contentstyle" NEXTRECT="layoutrect2"/>
</IE:DEVICERECT>

<IE:DEVICERECT ID="page2" CLASS="masterstyle" MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect2" CLASS="contentstyle" ONLAYOUTCOMPLETE="setTimeout('CheckIfPrintRequested()', 100)"/>
</IE:DEVICERECT>

</BODY>
</HTML>

Next: A final word

http://www.internet.com

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: August 27, 2001
Revised: August 27, 2001

URL: http://www.webreference.com/js/column91/6.html