Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Mike S Newsgroups: comp.lang.javascript Subject: Re: OT : min. requirements for printing web page content Date: Thu, 7 Apr 2016 23:45:40 -0700 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 8 Apr 2016 06:42:23 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a5284c76050eadfdd14f010f47941c37"; logging-data="25271"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8ZNNdiADJY1I84qR5V26A" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Cancel-Lock: sha1:CVZ7+edj7ubvLnGeElRSLgYfng0= Xref: csiph.com comp.lang.javascript:30237 On 4/6/2016 2:41 AM, Teodor V. wrote: > On 2016-04-06 09:00, Mike S wrote: >> On 4/5/2016 7:33 PM, Stefan Ram wrote: >>> Mike S writes: >>>> Iow can I ignore everything but the content I >>>> want to print and use html tags to formate it, like maybe just >>>> formatting the content in a new div and printing that? >>> >>> Yes. Copy the content to a new window. »w = window.open ...«, >>> »w.write( contents )«, »w.print ...«. >>> >>> If you have a popup-blocker: Use a custom css for printing, >>> which will hide everything but the content. >>> >>> Or: Save the old document in a variable. Replace document by >>> content. Print. Restore old document. >>> >>> In jQuery, see »printElement«. >>> >> printElement looks good. >> >> http://www.bennadel.com/blog/1591-ask-ben-print-part-of-a-web-page-with-jquery.htm > > FWIW, the CSS approach is the most compatible for users who fly with > Javascript disabled. > I use it the pages I design, minimal CSS and formatting, just enough to > produce a clean printout. > > /Teo. Thanks /Teo