Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Printing part of a page

Reply
Thread Tools

Printing part of a page

 
 
robert.spam.me.senseless@gmail.com
Guest
Posts: n/a
 
      04-13-2005
This is probably a real n00b question, but I can't find an answer on
the www and my javascript book doesn't have anything about it.

How do you print part of an html page using the javascript print()
function? Is it possible to put the printable area inside a
<div></div> block and print it, or can you use a hidden style then
print it?

Is there a site on the www which has some information?

 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      04-13-2005
In article <(E-Mail Removed) .com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...
> This is probably a real n00b question, but I can't find an answer on
> the www and my javascript book doesn't have anything about it.
>
> How do you print part of an html page using the javascript print()
> function? Is it possible to put the printable area inside a
> <div></div> block and print it, or can you use a hidden style then
> print it?
>



I haven't found a way with normal javascript (as opposed to MSIE HTA
JScript/WSH/ActiveX type deals), but if you do, please let me know, too. I've
been looking for a way to do this as well.

Okay, I found a way, but it was a PITA with changing print styles and I
decided it was too much of a boar to bother with.

CSS does support only printing certain things on a page, if that works for
your situation.

--
--
~kaeli~
Who is General Failure and why is he reading my hard disk?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-13-2005


(E-Mail Removed) wrote:

> This is probably a real n00b question, but I can't find an answer on
> the www and my javascript book doesn't have anything about it.
>
> How do you print part of an html page using the javascript print()
> function? Is it possible to put the printable area inside a
> <div></div> block and print it, or can you use a hidden style then
> print it?


You can design a CSS stylesheet that suggests how to print the page then
if you call window.print() the browser prints the page following the CSS
rules in the print stylesheet e.g.
<link rel="stylesheet"
media="print"
type="text/css"
href="print.css">
then in the print.css you could for instance have
div#navigationBar { display: none; }
to avoid having the navigation bar (in the <div id="navigationBar">)
printed.

IE also supports event handlers onbeforeprint/onafterprint so there you
could dynamically toggle the display of certain elements in the page.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
robert.spam.me.senseless@gmail.com
Guest
Posts: n/a
 
      04-14-2005
I'm going to try the suggestion below. It is possible to print the
contents of a frame - you can put all of the navigation stuff into a
separate frame and print using something like this:

<input type="button" value="Print"
onClick="parent.right.print();">

I have another page that doesn't use frames and it would be a big pain
to convert it to frames - hence the question.

 
Reply With Quote
 
robert.spam.me.senseless@gmail.com
Guest
Posts: n/a
 
      04-14-2005
Forget what I just put above - the stylesheet suggestion works a treat.

Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 2 11-27-2010 12:12 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM



Advertisments