printing

They have: 122 posts

Joined: Jun 1999

ok, I want a fnction to take place rightbefore printing and after printing. On the page, I have a button that prints the page and also shows the layer I want to print, and hides it back after a short white (accomplished with one function). That print button works, but what if the person presses Cntrl + p or prints it with a file|print ??? In ie 5.0 + (maybe 4.0), you can do onbeforeprint and onafterprint, but what about in netscape and if it doesn't work in ie 4.0, then what about that? The reason being is because on my website I have a button they click ot print that makes shows and unhides one layer, making that the only layer to print, but not everyoen one is going to use my button, and they might try to do it themselves. I just want something to happen when the person tries to print the page without clicking on the button I have provided...is there a way to do that?

The reason I want this is because I just want one image to print out without any pop-ups etc... I have been looking at CSS (2 I think) where they have @media print. I want everything else nto to print and my img.member to print, how would I do this?

@media print
{
img.member {display:inline}
#else {display:none}
}

The else thing is obviously wrong, but I want to do something like that.

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

Hmm... I don't know how to fix it.. but I can say CSS won't allow if/else (as far as I know). To do that you would need to use some JavaScript, VBscript, etc.

Hopefully someone here has a solution that will help you out more.

They have: 2 posts

Joined: Aug 2013

I hope I understand Your question.

Simply: add a class to everything You want to print, and hide everything else.

@media print {
* {
display: none;
}

.printable {
display: block;
}

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.