faqts : Computers : Programming : Languages : JavaScript : Document

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

I need to be able to only print the layer in an html page, any suggestions

Sep 10th, 2006 12:34
Tom Kopke, Nic Crow,


It would be easier to do this using stylesheets with a print specific 
styles to manipulate the class elements. The below example is very 
generic but works. On screen, you'll see both lines display. For print 
(or print preview), you'll see just one. Make sure that the "print" 
style sheet follows the main style sheet since they are implemented in 
the order found.
-----------------------
<html>
<head>
<style type="text/css" media="all">/*main site styles*/</style>
<style type="text/css" media="print">
.morestuff {display: none;} 
/*plus any other elements not to be printed*/
.stuff {display: block;}
/*plus any other elements to be printed*/
</style>
</head>
<body>
<div class="morestuff">more whatever</div>
<div class="stuff">whatever</div>
</body>
</html>