views:

9406

answers:

5

When I print a webpage from Internet Explorer it will automatically add a header and footer including the website title, URL, date, and page number.

Is it possible to hide the header and footer programatically using Javascript or CSS?

Requirements:

  • works in IE 6 (no other browser support necessary as its for an Intranet)
  • may use ActiveX, Java Applet, Javascript, CSS
  • preferably not something that the user needs to install (eg. http://www.meadroid.com/scriptx). feel free to list other third party available plug-ins though as I think this may be the only option
  • don't require the user to manually update their browser settings
  • don't render the pages as PDF or Word document or any other format
  • don't write to the registry (security prevents this)

Thanks

+8  A: 

In your print options you can disable this. The only way to do it programatically is with an activeX control which writes to the registry or a script block which is written in VB. The settings for your print options are stored in the registry. The user would have to allow your script to access the registry which most people wouldnt because of security.

If you want to control page content, you can use a css print stylesheet.

Edit: There are 3rd party active x controls which can programatically print for you, but once again, the user would have to choose to download and install it.

Jobo
A: 

You can use a print stylesheet to change the layout of your page when it is being printed.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
 <head>
  <title>Untitled Document</title>
  <style type="text/css" media="screen">
   #screen {}
   #print {
    display: none;
   }
  </style>
  <style type="text/css" media="print">
   #screen {
    display: none;
   }
   #print {}   
  </style>
 </head>
 <body>

  <div id="screen">You'll see me in your browser!</div>
  <div id="print">But you will only see me when you print!</div>

 </body>
</html>
Gavin
The question refers to hiding the page header and footer that are added onto the page when you print. They can't be hidden by CSS.
molasses
D'oh, someone clearly didn't read the entire question properly lol
Gavin
A: 

Hi,

I have tried the above code in my HTML between and

but the header and footer is still seen in the print output.

Kindly help me with a Java code/ HTML code such that i am able toremove the header and footer from the print.

Best Regards, Roja

Roja
Please refer to the answer from Jobo (ie. it can only be done using ActiveX or a 3rd party plugin). The answer from Gavin is incorrect.
molasses
+1  A: 

Hello, I think you can not control it with javascript. In my opinion, there is only option to use ActiveX in IE. I am still looking for the answer.

Good luck.

Jay
A: 

Hi all,

I do some googling and everybody said: "Can't remove them!" except using ActiveX and 3rd party plugins.

I wonder why some reporting controls (Telerik Reporting, DevX,...) can hide Header & Footer without using ActiveX or plugins! Are they print the page in another ways? What way?

Vinh