<html>
<head>
<script language="javascript">
var gAutoPrint = true;
function processPrint() {
if (document.getElementById != null) {
var html = '<HTML>\n<HEAD>\n';
if (document.getElementsByTagName != null) {
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0) html += headTags[0].innerHTML;
}
html += '\n</HE' + 'AD>\n<BODY '+((gAutoPrint)?'onLoad="window.print()"':'')+'>\n';
var elems = document.getElementsByTagName("div");
var divContent = "";
for (var i=0;i<elems.length;i++) {
if (elems[i].className=="printMe") divContent += elems[i].innerHTML+'<br />';
}
if (divContent!="") {
html += divContent;
html += '\n</BO' + 'DY>\n</HT' + 'ML>';
var printWin = window.open("","processPrint");
printWin.document.write(html);
printWin.document.close();
}
else alert("Error, no contents.");
return false;
}
}
</script>
</head>
<body>
<div class="printMe" > This is the content for printMe </div>
<div class="printMe" > This is the other content for printMe on the same page </div>
<a href="#" onClick="return processPrint();">Print</a>
</body>
</html>
|