最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Hide header and footer when printing from Internet Explorer using Javascript or CSS - Stack Overflow

programmeradmin0浏览0评论

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. ). 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

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

Share Improve this question edited Jan 16, 2009 at 1:10 molasses asked Jan 16, 2009 at 0:06 molassesmolasses 3,3186 gold badges24 silver badges22 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 9

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.

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.

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?

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">
<html xmlns="http://www.w3.org/1999/xhtml">
    <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>
发布评论

评论列表(0)

  1. 暂无评论