how to limit the print area

i dont want to print the whole page

Page 1 of 1

7 Replies - 5653 Views - Last Post: 28 January 2009 - 09:16 AM Rate Topic: -----

#1 pretender19  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 23-December 08

how to limit the print area

Posted 23 January 2009 - 10:01 AM

does anyone knows how to print page for a website?
im making a website where the user can print the page, i'd found a code in javascript but it print out the whole page(even the unnecessary part of the page)..

the user search in my site then print out the search result..

what i want is to print the search result ONLY..

thanks in advance...
Is This A Good Question/Topic? 0
  • +

Replies To: how to limit the print area

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: how to limit the print area

Posted 23 January 2009 - 10:08 AM

You could offer a link to a printer friendly version, which uses the same data but doesn't display all the extra page elements.
Was This Post Helpful? 1

#3 pretender19  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 23-December 08

Re: how to limit the print area

Posted 24 January 2009 - 08:31 PM

i dont understand.. is there any site that you can recommend for my prob? i'd tried googling it but the results are for "printing the whole page".
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2982
  • View blog
  • Posts: 10,297
  • Joined: 08-August 08

Re: how to limit the print area

Posted 25 January 2009 - 01:26 PM

I believe that thehat's point was that you, the web developer, would need to create a separate PHP function or class that would output only the things you want printed, leaving out ads or other extraneous information. You would give the user a link to this capability in your site.
Was This Post Helpful? 0
  • +
  • -

#5 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 452
  • View blog
  • Posts: 811
  • Joined: 17-June 08

Re: how to limit the print area

Posted 26 January 2009 - 11:21 AM

You can do this in CSS with media-specific styles. You just need to specify print media styles that hide what you don't want printed. For example:
@media print {
	#right_column, .advert {
		display: none;
	}
}


Was This Post Helpful? 1

#6 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: how to limit the print area

Posted 26 January 2009 - 11:26 AM

You can do that, and it had completely slipped my mind! What I meant was that he should link to a separate page that may even be laid out differently to ensure the document works well on paper and doesn't use unnecessary sheets.
Was This Post Helpful? 0
  • +
  • -

#7 pretender19  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 23-December 08

Re: how to limit the print area

Posted 28 January 2009 - 08:54 AM

can you give me an example for this... i dont have any idea...
Was This Post Helpful? 0
  • +
  • -

#8 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: how to limit the print area

Posted 28 January 2009 - 09:16 AM

To give you an idea of Adahacker's idea, then all you need to do is write a new stylesheet that hides all the unnecessary stuff on your page and link it in as a print stylesheet. Make sure this stylesheet comes last in your list of stylesheets.
<link rel="stylesheet" href="mymainstyles.css" media="all" />
<link rel="stylesheet" href="mydisplaystyles.css" media="screen" />
<link rel="stylesheet" href="myprintstyles.css" media="print" />


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1