Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print from webpage using Javascript

Status
Not open for further replies.
Joined
Mar 14, 2002
Messages
711
Location
US
I have this script which I found online in a help forum and it works very nice, except now I want to try to learn more about formatting it so I can set page margins, etc.

This is the script:

<script language="javascript">

function CallPrint(divPrint)
{
var prtContent = document.getElementById(divPrint);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>

How can I go about setting page margins = 0.25 all around, etc, etc.

Thanks for any help!
 
You can't reliably do this with JavaScript. Your best bet is to set up a print CSS, or use an ActiveX control (for IE only, unfortunately).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top