Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing print headers and footers?

Status
Not open for further replies.

styleBunny

Technical User
Jun 20, 2002
133
AU
Hi yall,

I have a printer friendly page (a word document exported to html, e That a side, is there any kind of code i can put in the page that will over ride the users local print settings? The settings which print the title of the web page and the url at the top and bottom of the printed page. These headers and footers are throwing the flow of my pages content all outta wack when its printed.

You can remove the locally / manually by going file > Page Setup > headers and footers. I am interested to hear if anyone know how to block them?

Cheers
SB
 
Use print stylesheets. You can hide unwanted columns / trim sections according to your printing requirements using the print style sheet.

Example.,

/* dont display header and menu in the print friendly version */
#l-header, #l-menu{
display: none;
}

/* reduce the height */
#l-main{
height: 400px;
}

etc...
 
Hi mex,

Yes that does work, tho the header and footer i am refering to arent part of my page. The header and footer i am refering to are the print header and footer added automatically by ie when you print a page. They usually display the page title and or the page's url.

thanks tho, that is a handy display setting none the less.
sb.
 
styleBunny

Those properties are to be found in the registry, and by default IE will have headers and footers.

If you were to instantiate an instance of Internet Explorer through a third party app, VB, Delphi, etc, you could save the registry values, replace them with the values required, programatically print and then immediately restore the values to the registry.

Assuming that not to be the case changing these values could still be done programatically but you really need the consent of the user before making such changes and should be able to change them back if needed.

Users can make the changes themselves through 'File > Page Setup...' on the IE menu and removing the strings in the Header and Footer textboxes.

Remembering those strings may be difficult amd should be copied to a text file for subsequent replacement.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.co.uk
 
Hi chris,

Thanks for that, furter looking as yielded no easy fix, so i might have to look at reformatting the page slightly. Grr!

Thanks for the info tho,
SB

 
I experimented with this a while back. I found a VB script that will remove the headers, then put them back.
Code:
<script Language="vbscript">
    Dim WSHShell
    Dim myHeader
    Dim myFooter
    Set WSHShell = CreateObject("WScript.Shell")
    myHeader = WSHShell.RegRead("HKCU\Software\Microsoft\Internet Explorer\PageSetup\header")
    myFooter = WSHShell.RegRead("HKCU\Software\Microsoft\Internet Explorer\PageSetup\footer")

    WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\header", ""
    WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\footer", ""

    Sub ResetHeader()
        Dim WSHShell
        Set WSHShell = CreateObject("WScript.Shell")
        WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\header", myHeader
        WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\footer", myFooter
    End Sub
</script>
Now, here's the trick. The user has to have "Allow ActiveX controls not marked as safe" checked in their IE setting for this to work, and I don't think it's checked by default. (BTW I believe this script is IE only) Also, this script removes the header/footer with no problem, but it won't replace them unless the user clicks on a link to reset them. On my pages, I have this link at the top which will close the page and also reset the headers.
Code:
<A HREF="JavaScript: close();" OnClick=ResetHeader()>Click Here to Close this Window</A>
But, if a user does not click on the link, the headers will not be reset.



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top