How to add a print current page function

L

laurence chang

How can I add a print link or button to print current page instead of
going to file print? Thanks ahead.

Laurence
 
S

S. Justin Gengo

Laurence,

Attach a javascript to a button on the page like this:

PrintThisPageLinkButton.Attributes.Add("onClick", "javascript:print();return
false;")



--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

Here is my solution: In the head of the page (in this case, a coupon page
the customer can print out) I placed the following Javascript block:


<script language="javascript">
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
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();
}

</script>


In the body of the page, I reference the Javascript from a HREF link.

<P align="center"><FONT color="#000000" size="2"><A
href="javascript:CallPrint('divPrint')">Print</A></FONT></P>


I hope this helps!

Andre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top