Print Templates, Part I: Code Listing of A Dynamic Print Template - Doc JavaScript | WebReference

Print Templates, Part I: Code Listing of A Dynamic Print Template - Doc JavaScript


Print Templates, Part I

Code Listing of A Dynamic 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>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var lastPage = 1;
function addFirstPage() {
  newHTML  = "<IE:DEVICERECT ID='devicerect1' MEDIA='print' CLASS='masterstyle'>";
  newHTML += "<IE:LAYOUTRECT ID='layoutrect1' CONTENTSRC='2.html'" +
             "ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect2'" +
             "CLASS='contentstyle'/>";
  newHTML += "</IE:DEVICERECT>";
  devicecontainer.insertAdjacentHTML("afterBegin", newHTML);
}
function onPageComplete() {
  if (event.contentOverflow) {
    document.all("layoutrect" + lastPage).onlayoutcomplete = null;
    newHTML  = "<IE:DEVICERECT ID='devicerect" + (lastPage + 1) +  
               "' MEDIA='print' CLASS='masterstyle'>";
    newHTML += "<IE:LAYOUTRECT ID='layoutrect" + (lastPage + 1) + 
               "' ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect" + 
               (lastPage + 2) + "'  CLASS='contentstyle'/>";
    newHTML += "</IE:DEVICERECT>";
    devicecontainer.insertAdjacentHTML("beforeEnd", newHTML);
    lastPage++;
  }
}
// -->
</SCRIPT>
<BODY ONLOAD="addFirstPage()">
<DIV ID="devicecontainer">
<!-- Pages created on the fly go here. -->
</DIV>
</BODY>
</HTML>
</BODY>
</HTML>

Next: A Final Word

http://www.internet.com


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

URL: http://www.webreference.com/js/column89/9.html