As long as the targetted browser is IE >= 5 you can use the onbeforeprint
and on afterprint events in javascript
(I found this out yeterday)
I wrote the code below to hide a print button and decrease the width when
the document is printed
Hope this helps,
mortb
<head>
<script language="javascript">
var originalWidth;
function window.onbeforeprint()
{
originalWidth = document.getElementById('_tblResult').style.width;
document.getElementById('_tblResult').style.width = '625px';
document.getElementById('_btnPrint').style.display = 'none';
}
function window.onafterprint()
{
document.getElementById('_tblResult').style.width = originalWidth;
document.getElementById('_btnPrint').style.display = 'inline';
}
</script>
</HEAD>
"Tigger" <Ti****@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Dear Experts,
I've got a trouble problem that I need your help. The scenario is the
following:
1) I need to add a "Print" button to my web page;
2) by clicking this button, the web page should be able to print out a
well-formatted web page (printer friendly ). That means, I need to adjust
the
printing margins (left, top, right, bottom) programmatically.
I really have no idea on how to achieve this but I know this is a very
typical scenario. Could you please give me some advices? Please help.
Thanks a lot.
Tigger