473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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?

Jul 23 '05 #1
4 21646
In article <11**********************@g14g2000cwa.googlegroups .com>,
ro**********************@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

Jul 23 '05 #2


ro**********************@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/
Jul 23 '05 #3
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.

Jul 23 '05 #4
Forget what I just put above - the stylesheet suggestion works a treat.

Thanks.

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PFMcCracken | last post by:
We have a database search page written in ASP. One of the information pages does not print properly because the windows background printing reloads the page, but does not wait long enough to...
5
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using...
3
by: Tim | last post by:
Hi, I am creating my own method for printing. I am using PrintDocument and cycling through the data and creating new pages as neccessary. My question is, how can I know that total number of...
5
by: Tom | last post by:
I am converting an old application that was printing directly to a specialized printer device (i.e. a special label printer). It was doing this by opening a file with the file path of 'LPT1:' and...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
0
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom...
0
by: dotnet2005 | last post by:
Hi Toall , I want to explain you clearly , I am having some panels having some controls CheckBox,ComboBox,Datagridview,Hyperlink,label,Listbox,Picturebox,RadioButt­ on ,Textbox)...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.