spacer

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

home / experts / javascript / column92


Print Templates, Part III: HeaderFooter

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


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