spacer

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

home / experts / javascript / column92


Print Templates, Part III: HeaderFooter

Product Designer
Aquent
US-WA-Redmond

Justtechjobs.com Post A Job | Post A Resume
Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

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

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: September 10, 2001
Revised: September 10, 2001

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