Log in

View Full Version : Printing a section of a page



Scrounger
01-13-2008, 10:04 PM
If you look on my website, www.cubpack88.org, you will see a calendar towards the bottom of the page. If I want to use a script to just print out that table without using an alternate document. I'm using a print redirect with <link rel=alternate media=print href="http://www.cubpack88.org/print_redirects/upcoming_events.doc"> WHen I try to print the page always comes out blank. ANy suggests on what I can do to fix this. I've tried it with the file outside of a folder but it wont work that way either.

This one has me really stumped.

Regards,

Matthew

Medyman
01-13-2008, 11:01 PM
You can also easily control what parts of your page print out by adding a special stylesheet that will be used for printing to the <head> section of your page like this


<link rel="stylesheet" href="print.css" type="text/css" media="print" />

The print.css file should contain the following:

body {visibility:hidden;}
.print {visibility:visible;}

Now all you need to do is to assign class="print" to whatever parts of your web page that you want to have print out. Anything on the page not assigned to this class will not print.

Master_script_maker
01-13-2008, 11:02 PM
http://personalweb.about.com/od/copypastejavascripts/a/404_3scripts_3.htm

Scrounger
01-16-2008, 03:38 AM
I like how this will work but inside FrontPage I'm stuck on how you assign a class to a table without doing it in the code. I want to use the FrontPage interface to do it. Can I do it that way or do I have to do it in the code.

Regards,

Matthew

Scrounger
01-16-2008, 04:32 AM
http://personalweb.about.com/od/copypastejavascripts/a/404_3scripts_3.htm

I've tried this one for a few days and I can't get the button or the text to appear to get the page to print.

I can't figure out what I'm missing, this shouldn't be this hard.

jscheuer1
01-16-2008, 07:53 AM
You need to be precise with stylesheets. If you have one for the screen and one for the printer, each should be labeled as such so its styles cannot 'spill over' to the other:


<link rel="stylesheet" href="screen.css" type="text/css" media="screen">
<link rel="stylesheet" href="print.css" type="text/css" media="print">

Also the suggestion given here:



body {visibility:hidden;}
.print {visibility:visible;}

will never work because visibility is inherited - unless you have content outside the body, which is wrong to do anyway. If the entire body is hidden, nothing in it can be seen.

When adding class names to elements, it is often easier to use a text only editor like notepad.