![]() |
Printing part of a page
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? |
Re: Printing part of a page
In article <1113381063.225212.164710@g14g2000cwa.googlegroups .com>,
robert.spam.me.senseless@gmail.com 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 |
Re: Printing part of a page
robert.spam.me.senseless@gmail.com 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/ |
Re: Printing part of a page
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. |
Re: Printing part of a page
Forget what I just put above - the stylesheet suggestion works a treat.
Thanks. |
| All times are GMT. The time now is 08:38 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.