Page 1 of 1

print preview code

Posted: Thu May 17, 2007 4:38 pm
by izzysanime
Hi,

Another question, Im looking for code that will print only specific parts of the page.  maybe put the content into a div tag?

Thanks
Josh

Re: print preview code

Posted: Thu May 17, 2007 4:54 pm
by tsw
create a print stylesheet which has something like

* {display:none}

#content {display:block;}

Re: print preview code

Posted: Thu May 17, 2007 5:25 pm
by izzysanime
I tried using this

http://javascript.internet.com/miscella ... eview.html

but how do you specify what gets printed?

Re: print preview code

Posted: Thu May 17, 2007 7:06 pm
by Kayin
examples are meant to point you in the right direction, not give you the answer.

Use what was written above

* {display: none}
#content {display: block}

if you have different parts that you want to print....  what's the logical step here?

-K

Re: print preview code

Posted: Thu May 17, 2007 7:16 pm
by izzysanime
I don't necessarily want the answer, but a little more direction.  what i have tried was giving the content i want printed a div id, but that does not work.  Is that what you meant? 

Thanks
Josh

Re: print preview code

Posted: Thu May 17, 2007 7:48 pm
by Kayin
You're using tables. Divs and tables act funny with each other because they're essentially trying to do the same thing just in different ways.

Keep messing with it, try different things like giving a table an id instead of using a div and then setting that to display:none;

-K

Re: print preview code

Posted: Thu May 17, 2007 10:27 pm
by izzysanime
ok, this is starting to make much more sense, but now the print button does not do anything.  I gave the div an id and removed the table, and the css file has the id info set to none like you said.
Am I supposed to change the print button to something else?
 

Thanks
Josh

Re: print preview code

Posted: Thu May 17, 2007 10:39 pm
by izzysanime
ok, i just realizsed i had to click the print button on the browser.  OK, i also changed my print button just to a standard print command.  So this is done, now need to fix other one remaining.

Thanks again Kayin for your help

Josh