Hide IE's header and footer when printing

P

Peter

Hi

I have a button control in my code to print the page but every time it prints out the IE's header and footer's settings like doing
the File/Print option.

<input type="button" onClick="window.print()" class="hide" value="Print"/>

Any easy way to not printing the header/footer for that button ?

Thanks
Peter
 
G

Gregory A. Beamer

Hi

I have a button control in my code to print the page but every time it
prints out the IE's header and footer's settings like doing the
File/Print option.

<input type="button" onClick="window.print()" class="hide"
value="Print"/>

Any easy way to not printing the header/footer for that button ?

Thanks
Peter

Do you mean the page information?

Regardless, you can set up a print CSS stylesheet to get rid of things, or
include them.
 
G

Guest

Hi

I have a button control in my code to print the page but every time it prints out the IE's header and footer's settings like doing
the File/Print option.

<input type="button" onClick="window.print()" class="hide" value="Print"/>

Any easy way to not printing the header/footer for that button ?

Thanks
Peter

Peter,

if header/footer is a part on the page, you can try to hide it using
media type of CSS
http://www.w3.org/TR/CSS2/media.html

The following example will show header and button on the screen but on
printer only the body will be printed out.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>Link to a target medium</TITLE>
<style>
@media print {
.header, .hide { visibility: hidden }
}
</style>
</HEAD>
<BODY>
<DIV class="header">The header</DIV>
<P>The body...</P>
<input type="button" onClick="window.print()" class="hide"
value="Print"/>
</BODY>
</HTML>
 
P

Peter

What I mean is the "header" and "footer" in the IE Page Setup. Can you show me the way to remove them ?

Thanks
Peter
 
P

Peter

Thanks Alexey but seem doesn't work. Any other ways I can try to remove those IE's headers and footers ?

Thanks
Peter

Hi

I have a button control in my code to print the page but every time it prints out the IE's header and footer's settings like doing
the File/Print option.

<input type="button" onClick="window.print()" class="hide" value="Print"/>

Any easy way to not printing the header/footer for that button ?

Thanks
Peter

Peter,

if header/footer is a part on the page, you can try to hide it using
media type of CSS
http://www.w3.org/TR/CSS2/media.html

The following example will show header and button on the screen but on
printer only the body will be printed out.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>Link to a target medium</TITLE>
<style>
@media print {
.header, .hide { visibility: hidden }
}
</style>
</HEAD>
<BODY>
<DIV class="header">The header</DIV>
<P>The body...</P>
<input type="button" onClick="window.print()" class="hide"
value="Print"/>
</BODY>
</HTML>
 
G

Guest

What I mean is the "header" and "footer" in the IE Page Setup.   Can you show me the way to remove them ?

Thanks
Peter

Well. this is client setup and cannot be controlled on server. Forget
it
 
G

Guest

Thanks Alexey but seem doesn't work.   Any other ways I can try to remove those IE's headers and footers ?

My example was about html parts and not about browser settings. Now I
see what you mean. You can't change printer preferences from the
website.
 
P

Peter

But I have actually visted some private pages written with ASP.net actually did the job removing the header and footer when printing
using a internally built button control inside the page but I don't know how this can be done. I have tried using the registry
method but don't know why the Key always returned NULL and displayed "ABC" with the code below. Any suggestions ?

-----
RegistryKey pageKey;

String keyValue = "Software\\Microsoft\\Internet Explorer\\PageSetup";
String curFooter;
pageKey = Registry.CurrentUser.OpenSubKey(@keyValue, false);
if (pageKey != null)
{
if (pageKey.GetValue(@"footer",0) != null)
{
curFooter = (String)pageKey.GetValue(@"footer");
Response.Write ("--" + curFooter + "--<BR>");
}
else
{
Response.Write ("DEF<BR>");
}

}
else
{
Response.Write ("ABC<BR>");
}

----
Thanks Alexey but seem doesn't work. Any other ways I can try to remove those IE's headers and footers ?

My example was about html parts and not about browser settings. Now I
see what you mean. You can't change printer preferences from the
website.
 
G

Gregory A. Beamer

What I mean is the "header" and "footer" in the IE Page Setup. Can
you show me the way to remove them ?


Sans popping the page up in another browser window with something like
window.open() in JavaScript, you cannot selectively show/hide browser
elements.
 
P

Peter

Thanks for your clarifications.

Peter

Patrice said:
This code runs server side so you change the registry server side which
won't help...

It could be possible to alter this but the user will have likely to give
its consent to install something client side (not sure what is the button
you are talinkg about). If it bypasses the usual IE dialog this is
definitely something installed client side (which requires user consent).

Perhaps something like ScriptX
(http://www.meadroid.com/scriptx/about.asp). itn could be perhaps also by
hsioitng a webcontrol isnide the HTML page but then if you have
sophisticated needs it could be better to produce a real report rather
than printing a web page...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top