473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to add a print current page function


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

Laurence


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
2 4746
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
"laurence chang" <la************@rogers.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...

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

Laurence


*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #2
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,t oolbar=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
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rich | last post by:
i have a web page that uses a javascript function to show/hide some info using css "visibile" "hidden" attributes of "id". the js was a free script that i modified for my use. works great. to...
1
by: SAN CAZIANO | last post by:
I have to insert a button in the left of all record in a table to print the current record, simply create a table and print it in the printer. anyone have an idea or there is a printer/report...
1
by: nospam | last post by:
All I am trying to achieve the following: Main window page's asp code writes the following line to launch a popup window (note the IFRAME has to be in the popup window, it cannot be in the...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
4
by: Peter | last post by:
ASP.NET 1.1 Does anyone has an example where user can click on an link or button and print the current page? Thanks Peter
0
by: MadhuriY | last post by:
Hi, I am working on Bea Weblogic Portal. For every page we have singlelevelmenu.jsp, footer.jsp, rightnavigation.jsp and portlets rendered between them. In the footer.jsp we have a print...
1
by: ruca | last post by:
Hi, I have a button that when clicked must print the current page after doing something in a certain function. For that I have this code: ...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.