View Full Version : is there a way to print the content of a div?

10-18-2006, 03:05 PM

I have a page which contains driving directions to my lab at school. The directions are segmented by direction you are comming from (so 'From East, From West, Public Transportation, etc')

What I want to do is provide a link so that users can print whichever directions they need without printing the whole page. Currently the different sections are seperated in divs with different ID's.

Is there a way / is it simple to have a print button which would only print the content of 'div X'...

alternatively, i suppose i could create little .htm files with the seperate directions in each and somehow call that print using something akin to window.print('fromEast.htm');

any suggestions?

10-18-2006, 03:40 PM
You could use css-link a file that only prints your div:
set the media attribute in the source to 'print'


10-18-2006, 08:35 PM
I suppose what I was trying to do is to avoid having the same text twice. if I can't then i will figure out an alternative.

i dont suppose there's a js way to say "onclick, add this classname to the div containing this link" ... and that classname would set the media=print only

or am i dreaming in technicolor?