Randy said:
I don't think I want to give myself a headache trying to understand what
you just attempted to say as it doesn't make any sense at all.
Maybe a working sample may help (naturally IE only, try either
File>Print or File>Print preview).
<html>
<head>
<title>Print</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<style type="text/css">
@media screen {
div {
font: bold 10pt Verdana, Geneva, sans-serif;
color: #000099;
}
body {
background-color: #FFFF99;
}
}
@media print {
div {
font: bold 10pt Verdana, Geneva, sans-serif;
color: #000000;
}
body {
background-color: #FFFFFF;
}
}
</style>
<script type="text/javascript">
function init() {
document.documentElement.onlayoutcomplete = stage1;
window.onbeforeprint = stage2;
window.onafterprint = stage3;
setTimeout('window.print()');
}
function stage1() {
alert('stage1');
/* On this stage browser defines what document
* to print (because an alternate document can be defined).
* It also prepare print template using defined LayoutRect if any.
* For databound elements actual value corresponding to
* the applied filters is retrieved.
* As nothing of this is presented in this sample, this event
* is not fired on HTML element.
*/
}
function stage2() {
alert('stage2');
/* On this stage browser prepares actual
* print layout. If media-specific styles are
* supplied (like in this sample) browser switches
* the "document image" from screen-styles to print-styles.
* After all this done the describing event is fired
* so you could make any last-minute DOM damages
* if you need too.
* After that PostScript "screenshot" is made and sent
* to the print pool.
*/
}
function stage3() {
alert('stage3');
/* The last bit of the PostScript stuff went to the pool.
* If any changes have been made on beforeprint,
* here is your chance to undo them for normal
* screen view.
*/
}
if (window.onbeforeprint === null) {
window.onload = init;
}
</script>
</head>
<body>
<div id="t1">Test page</div>
</body>
</html>