Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1437 How can I control the printing of header and footer information?

irt.org | Knowledge Base | JavaScript | print | Q1437 [ previous next ]

Q1437 How can I control the printing of header and footer information?

The following was submitted by John Roach:

Use the activeX control from http://www.meadroid.com/

The activex control allows resetting of a few of the web browser control's printing properties and will print the current web page. It also looks like for some money you can get an enhanced version that gives you more features such as printing any web document without displaying it in the browser. In our apps we needed to print some forms and reports and wanted to control the printing of header and footer info. Code is below. Our app is an intranet and Internet Explorer specific so not worried about Netscape Navigator. Haven't tried any other features other than resetting the header and footer. I just stored the user's existing header and footer and then reset when finished. The factory.DoPrint(false) perfoms the print and suppresses the print dialog box. factory.DoPrint(true) displays the print dialog box. It looks as if the DoPrint method also takes a frame name for printing individual frames on the page, but haven't tried it.

<script language="Javascript"><!--
function doprint() {
  //save existing user's info
  var h = factory.printing.header;
  var f = factory.printing.footer;
  //hide the button
  document.all("printbtn").style.visibility = 'hidden';
  //set header and footer to blank
  factory.printing.header = "";
  factory.printing.footer = "";
  //print page without prompt
  factory.DoPrint(false);
  //restore user's info
  factory.printing.header = h;
  factory.printing.footer = f;
  //show the print button
  document.all("printbtn").style.visibility = 'visible';
}
//--></script>
<body>
<br><br><br>
<object id=factory style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext codebase="ScriptX.cab#Version=5,0,4,185">
</object>
<br><br>
<div id="printbtn"><input name=idPrint type=button value="Print the letter" onclick="doprint()"></div>
</body>

Feedback on 'Q1437 How can I control the printing of header and footer information?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.