-2

Possible Duplicate:
How do I hide an element when printing a web page?

i am using below code for the print-- but if printing the full page. what do I have to do to print the limited area of the page (below the print button area)?

<SCRIPT LANGUAGE="JavaScript"> 
if (window.print) {
document.write('<form><input type=button name=print value="Print Page"onClick="window.print()"></form>');
}
</script>

The above script is working fine but for only the whole page.

Community
  • 1
  • 1
Kritika Gupta
  • 41
  • 1
  • 6

2 Answers2

2

Using CSS:

@media print{
  /* in here hide all elements you dont want printed e.g.:
   * div#header{ display: none; }
   */
}
Prisoner
  • 27,391
  • 11
  • 73
  • 102
  • Oh I got it. Need to put the code in css and related Div. Thanks a lot. – Kritika Gupta Jan 04 '13 at 10:23
  • Yeah, you can all the print function with javascript, but you need to define whats visible when printing the document in CSS (using the `media`) tag. – Prisoner Jan 04 '13 at 10:26
0

You can add @media print css where you will hide all elements on the page that you don't want to print. You can set them to display:none and they will not show on print page

v0d1ch
  • 2,738
  • 1
  • 22
  • 27