- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsHello,
I'm trying to print only part of a web page. For example, I would like to print everything within the <DIV> tag. I guess I just need help setting up the javascript. What I don't want to end up doing is creating another duplicate page just to have it be the Print-Friendly one. THis is the framework I have so far...
'This is the link that prints the page (actually the section of the page)
<a href="javascript:void(prin
'This is the javascript in the HEAD of my page:
<Script Language="Javascript">
function printSpecial()
var printReadyElem = document.getElementById("p
This is where I need help. I want to Print all content within the document.getElementById("p
</Script>
'This is my DIV tag
<div id="printReady">All my text and such I want actually printed will go in here.</div>
THank you,
Jayme
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: prohacxPosted on 2004-11-30 at 05:09:38ID: 12705294
Hi there Jayme!
There are 2 ways of solving this issue:
1. Remove all unnecessary content from your document using JavaScript
2. Use a nice stylesheet to solve your problem.
I'll explain the second one, since I believe this is the 'best' solution:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> CSS and printers </TITLE>
<style type="text/css">
@media screen {
.unprintable {
display: block;
}
.printable {
display: block;
}
}
@media print {
.unprintable {
display: none;
}
.printable {
display: block;
}
}
</style>
</HEAD>
<BODY>
<div class="unprintable">
some things unprinted here
</div>
<div class="unprintable">
some things unprinted here
</div>
<div class="printable">
PRINT THIS
</div>
<div class="unprintable">
some things unprinted here
</div>
<div class="unprintable">
some things unprinted here
</div>
</BODY>
</HTML>
As you can see, you can setup a styelsheet for each medium you use (screen, printer, handheld, ...) and determine what and how to display it on this medium. I use this way to hide buttons on printed forms, because clicking on the paper does not really do anything, does it? ;-)
Good luck!