Jump to content

how to eliminate header and footer in print


Guest manil22

Recommended Posts

Guest manil22

hi, all how to eliminate header and footer in printing document (in internet explorer)using java script. Is there any way to do this in java script.if, then give me the solution.

Link to comment
Share on other sites

CSS print formatting only formats the page but IE adds the headers and footers after the page is loaded to the print que.The only way to disable headers and footers without manually shutting them off is with ActiveX. This will only work with IE.Users will be prompted with a security alert, but if that works for you this is an ideal solution. If you download the code from the link http://www.meadroid.com/scriptx/sxdownload.asp extract the zip file and upload ScriptX.cab to your web space. (Be sure to use Binary FTP mode if you are on windows)Here is some example code to make it work, you just stick this right into your HTML output:

<HTML><HEAD><!--- JavaScript to operate the activeX object --><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></HEAD><BODY><object id="factory" viewastext  style="display:none"  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"  codebase="./ScriptX.cab#Version=6,1,431,2"></object><input type="button" name="printbtn" onClick="doprint()" value="Print"></BODY></HTML>

The above code will create a button with the text "Print" if the user clicks it, the printout will have no header/footer text added by the browser. The user will be prompted to install the activeX by a security dialogue if their security settings are set to medium or high on internet explorer. However, they will only need to click yes the first time they visit your page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...