Print Templates, Part III: HeaderFooter: Assembling the Header and Footer - Doc JavaScript | WebReference

Print Templates, Part III: HeaderFooter: Assembling the Header and Footer - Doc JavaScript


Print Templates, Part III: HeaderFooter

Assembling the Header and Footer

The main functionality of the HeaderFooter behavior is to synthesize the HTML of the header and footer. The HTML for the header is in the HeaderFooter's htmlHead property. The HTML for the footer is in its htmlFoot property. The inputs to this synthesis process are all other HeaderFooter properties. First and foremost are the instructions. These are strings that specify what should be assembled in htmlHead and htmlFoot, and how they should be assembled. These strings are in the textHead and textFoot properties. Other properties are also participating: url, title, and pageTotal.

We insert the header and footer HTML in two DIV elements, newHeader and newFooter. Once they are assembled, we insert the header at the beginning of the page, and the footer before the end of the page. The following addHeaderAndFooterToPage() function creates the HTML for the header and the footer, and inserts them into a page:

function addHeaderAndFooterToPage(pageNum) {
  newHeader = "<DIV CLASS='headerstyle'>" +
    myheaderfooter.htmlHead + "</DIV>";
  newFooter = "<DIV CLASS='footerstyle'>" +
    myheaderfooter.htmlFoot + "</DIV>";
  document.all("DEVICERECT" +
    pageNum).insertAdjacentHTML("afterBegin", newHeader);
  document.all("DEVICERECT" +
    pageNum).insertAdjacentHTML("beforeEnd", newFooter);
}

Next: How to add headers and footers while rendering


http://www.internet.com


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

URL: http://www.webreference.com/js/column92/4.html