spacer

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

home / experts / javascript / column92


Print Templates, Part III: HeaderFooter

Market Data Analyst (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume
Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans


Updating Headers and Footers

In template5, we need to assemble the HeaderFooter element at the beginning. We do it in addFirstPage():

  myheaderfooter.textHead = printer.header;
  myheaderfooter.textFoot = printer.footer;
  myheaderfooter.url =
    dialogArguments.__IE_BrowseDocument.URL;
  myheaderfooter.title =
    dialogArguments.__IE_BrowseDocument.title;

As in template4, we first fill HeaderFooter's textHead and textFoot properties. We just copy them from TemplatePrinter's header and footer properties. These properties reflect the user's entries in the Print Setup dialog box. We also populate the url and title properties from the document currently displayed. We take these properties from the document object that is passed through dialogArguments.__IE_BrowseDocument.

The other change from template4 is the addition of addPageTotalToPages(). In this function we update the total number of pages in all headers' "Page x of y" message. Here is the function:

function addPageTotalToPages() {
  oSpanCollection = document.all.tags("span");
  for (i = 0; i < oSpanCollection.length; i++) {
    if (oSpanCollection[i].className ==
    "hfPageTotal") {
      oSpanCollection[i].innerText =
        myheaderfooter.pageTotal;
	}
  }
}

This function is based on some implementation details of the HeaderFooter behavior. More precisely, on how it assembles the field of total number of pages in the header's HTML. The field is laid out within a SPAN element, and its className property is "hfPageTotal". The className property is one of the properties of the SPAN object. The function above simply searches for all SPAN elements of the page, finds the one with className property equal to "hfPageTotal", and updates its innnerText property with the total number of pages (myheaderfooter.pageTotal).

Next: Template4's code listing


http://www.internet.com


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger


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/6.html