tags:

views:

23

answers:

2

I have a Pape width different DIVs and a PRINT link. I want that if the user clicks on a Print link should a specific DIV be printed not the whole page.

A: 

Use print media stylesheets to set everything else to display: none (you'll need to construct your markup in such a way that nothing you want to print is a descendent of something you do want to print).

Toggle class names on the div elements to select which ones get printed.

David Dorward
+3  A: 

I think you can use CSS, like so:

@media print {
  body * {
    display:none;
  }

  #divToPrint {
    display:block;
  }
}

but I don't think this is supported on all browsers. The alternative would be to open the contents of the DIV in a new window, and then print that window.

EMMERICH
Any reason you use specifiy the `body` tag?
Tomas