6 Replies - 30200 Views - Last Post: 05 July 2006 - 11:54 AM

#1 kaushiks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 07-March 06

Printing In HTML

Post icon  Posted 04 July 2006 - 03:23 AM

hi,

I am new to html, so there are some basic things that i dont know.

Is there any code in html to print a page?
If we want to print a specific area and not the whole page how is it written in html?

Please guide me through this, coz i am a little confused in this printing functionality


regards,
kaushik
Is This A Good Question/Topic? 0
  • +

Replies To: Printing In HTML

#2 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Printing In HTML

Posted 04 July 2006 - 05:25 AM

I assume that you mean print like in print with a printer. You're going out of HTML here, as HTML's only job is to render. To print a page, you would have to use Javascipt window.print(). To trigger this you would of couse have to put an a tag around it like so <a href="window.print()"> or an onclick or something of the kind. Since javascript is kind of hierarchical, i guess that you could also put window.form.print() is you want to print a form window.iframe.print() to print an iframe. Go ahead and learn a little javascript at http://www.w3schools.com/
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Printing In HTML

Posted 04 July 2006 - 05:26 AM

There is no way to use HTML to send data to a printer, I'm afraid...you'll need a scripting language to do that.

[edit]Whoops...me and max were replying at the same time...max was quicker! :)[/edit]

This post has been edited by Amadeus: 04 July 2006 - 05:28 AM

Was This Post Helpful? 0
  • +
  • -

#4 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Printing In HTML

Posted 04 July 2006 - 05:54 AM

View PostAmadeus, on 4 Jul, 2006 - 04:18 AM, said:

There is no way to use HTML to send data to a printer, I'm afraid...you'll need a scripting language to do that.

[edit]Whoops...me and max were replying at the same time...max was quicker! :)[/edit]


I post faster than my shadow!
Was This Post Helpful? 0
  • +
  • -

#5 kaushiks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 07-March 06

Re: Printing In HTML

Posted 04 July 2006 - 11:13 PM

View Postmax302, on 4 Jul, 2006 - 04:46 AM, said:

View PostAmadeus, on 4 Jul, 2006 - 04:18 AM, said:

There is no way to use HTML to send data to a printer, I'm afraid...you'll need a scripting language to do that.

[edit]Whoops...me and max were replying at the same time...max was quicker! :)[/edit]


I post faster than my shadow!


guys what u r saying is alright, but how can we determine the area of page to print. For example top half of my web page has got banner on it, so i dont need to print that. say use window.form.print will print the form area.
What if i have got some tables to be printed ??

please enlighten me


regards,
kaushik
Was This Post Helpful? 0
  • +
  • -

#6 Arbitrator  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 51
  • View blog
  • Posts: 530
  • Joined: 26-January 05

Re: Printing In HTML

Posted 05 July 2006 - 03:48 AM

<style type="text/css">
  @import "print.css" print;
  @media print {
	#banner {
	  display: none;
	  }
	}
</style>

Was This Post Helpful? 0
  • +
  • -

#7 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Printing In HTML

Posted 05 July 2006 - 11:54 AM

View PostArbitrator, on 5 Jul, 2006 - 02:40 AM, said:

<style type="text/css">
  @import "print.css" print;
  @media print {
	#banner {
	  display: none;
	  }
	}
</style>


CSS does that? Wow... Another reason why CSS owns all.

But if you want to stay with javascript, learn how a page is heirarchically divided in JS and from there, you should find a solution to your problem, young padawan.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1