This is a mildly hacky way to do what you want without mucking with a separate window.
Code:
<html>
<head>
<style type="text/css">
@media print {
.noprint { display: none; }
.printme { display: block; }
}
#funk {
width: 50%;
border: solid red 3px;
}
.isblue {
border: solid blue 5px;
background-color: lightblue;
}
#zonk {
width: 40%;
}
</style>
<script type="text/javascript">
function printDiv( byId )
{
// this loop could use getElementByClassName if not using MSIE8 and below
var divall = document.getElementsByTagName("div");
for ( var d = 0; d < divall.length; ++d )
{
var div = divall[d];
div.className = div.className.replace("printme","noprint");
}
// now, turn "on" only one div for printing:
var div = document.getElementById( byId );
div.className = div.className.replace("noprint","printme");
window.print( );
}
</script>
</head>
<body>
<div id="funk" class="noprint">
<h1>Yowser!</h1><br/>
Want to print me?<br/>
<input type="button" value="Then click here!" onclick="printDiv('funk');"/>
</div>
<div class="noprint">
Stuff that will never get printed!
</div>
<div id="zonk" class="isblue noprint">
<h2>Coupon worth $2 million dollars!<h2>
<br/>
<i>Expires April 1, 1932</i>
<br/>
</div>
<a class="noprint" href="#" onclick="printDiv('zonk'); return false;">PRINT $2,000,000 COUPON</a>
</body>
</html>